answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,temp,a[7];

clrscr();

printf("Enter 7 integer numbers: \n");

for(i=0;i<7;i++)

scanf("%d",&a[i]);

for (i=0;i<7;i++)

{

for(j=i+1;j<7;j++)

{

if(a[i]<a[j])

{

temp=a[i];

a[i]=a[j];

a[j]=temp;

}

}

}

printf("\n\nThe 7 numbers sorted in ascending order are: \n");

for(i=0;i<7;i++)

printf("%d\t",a[i]);

getch();

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

#include<stdio.h>

#include<conio.h>

main()

{

int x;

printf("Enter the max number of array: ");

scanf("%d", &x);

int i;

int j;

int temp;

int a[x];

system("cls");

printf("Enter %d integer numbers: \n", x);

for(i=0;i<x;i++)

scanf("%d",&a[i]);

for (i=0;i<x;i++)

{

for(j=i+1;j<x;j++)

{

if(a[i]<a[j])

{

temp = a[j];

a[j] = a[i];

a[i] = temp;

}

}

}

printf("\n\nThe %d numbers sorted in ascending order are: \n", x);

int y = x - 1;

for(i=y;i>=0;i--)

printf("%d\t",a[i]);

getch();

}

// this is a converted to c code, this program will allow you to input how many numbers you want and having the same result. as the other one ...

note: thank you wherever you are for writing this code thanks a lot!!!

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

#include<stdio.h>

#include<conio.h>

main()

{

int num1,num2,num3,a[3];

printf("Enter 3 integer numbers: \n");

for(num1=0;num1<3;num1++)

scanf("%d",&a[num1]);

for (num1=0;num1<3;num1++)

{

for(num2=num1+1;num2<3;num2++)

{

if(a[num1]<a[num2])

{

num3=a[num2];

a[num2]=a[num1];

a[num1]=num3;

} } }

printf("\n\nThe 3 numbers sorted in descending order are: \n");

for(num1=0;num1<3;num1++)

printf("%d\t",a[num1]);

printf("\n\nThe 3 numbers sorted in ascending order are: \n");

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago
  1. #include
  2. int main()
  3. {
  4. int *array, num;
  5. cout << "How many integers do you wish to allocate?";
  6. cin >> num;
  7. array = new int[num+1];
  8. if (array == NULL)
  9. {
  10. cout << "Error allocating memory!\n";
  11. return;
  12. }
  13. cout << "Enter the integers here: \n";
  14. for (int count =0; count < num; count++)
  15. {
  16. cout << "Integer # " << (count +1) << ": ";
  17. cin >> array[count];
  18. }
This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Use the qsort() function ;)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to arrange 7 numbers in ascending order?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.


What does descending mean in maths?

In Maths, we often talk about ascending and descending order. Ascending order is writing numbers from smallest to largest. Descending order is writing numbers from largest to smallest.


Ascending order program for java?

public class BubbleSortAscendingOrderDemo { public static void main(String a[]) { //Numbers which need to be sorted int numbers[] = {23,5,23,1,7,12,3,34,0}; //Displaying the numbers before sorting System.out.print("Before sorting, numbers are "); for(int i = 0; i &lt; numbers.length; i++) { System.out.print(numbers[i]+" "); } System.out.println(); //Sorting in ascending order using bubble sort bubbleSortInAscendingOrder(numbers); //Displaying the numbers after sorting System.out.print("Before sorting, numbers are "); for(int i = 0; i &lt; numbers.length; i++) { System.out.print(numbers[i]+" "); } }


A C program using dynamic memory allocation to sort n names in ascending order?

Writing a C program that uses dynamic memory allocation to sort names in ascending order is a typical computer science assignment. To write this program, you must be in UNIX.


Algorithm and flow chart of the program for ascending and descending order of numbers?

Use a looping structure. The first step initialises a loop control variable, n, to zero. You then begin the loop by processing the nth element from the array (the process may be a simple print statement). You then increment n. Finally, you test the value of n; if it is less than 10 you start a new iteration of the loop, otherwise you proceed to the end of the flowchart.

Related questions

What will be the program to arrange numbers stored in array in ascending order using pointers?

sorry


Draw a flowchart to arrange 3 numbers in ascending order?

draw a flow chart to arrange 3 numbers in ascending order


Which way is ascending and descending?

Ascending order is when numbers are arranged from the smallest to the largest. Descending order is when numbers are arranged from the largest to the smallest.


How do you arrange 4 numbers in ascending order without array?

addends


What is it called when you arrange numbers from greatest to least?

This is known as arranging the numbers in ascending order.


How do you work out the median for a set of eight numbers?

Arrange the numbers in ascending order, and then take the mean of the fourth and fifth number.


How to find the smallest number?

When you are given some numbers just arrange them in ascending order and you will the smallest number which can be made out of those given numbers.


How do you arrange these numbers 22.8 8.2 8.02 28.2 2.8?

In ascending order: 2.8, 8.02, 8.2, 22.8, 28.2


How do you arrange the set of numbers 4.8 4.9 4.78 4.89 from least to greatest is what?

4.78 4.8 4.89 4.9 are the numbers arranged in ascending order.


How do you arrange 0.1 0 0.01 and 1.0 in order from least to greatest?

From ascending order, the numbers will be:0 , 0.01 , 0.1 , 1.0


How do you arrange words in cline and examples?

its arranged by ascending and descending order.........


If we arrange all the one digit odd numbers in ascending order and then in decending order to form five digit number what digit occupies the same place value?

5