See what questions your friends are asking today.

Write a C program to arrange 7 numbers in ascending order?

View Slide Show

Close
Answer:
#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!!!

More on: C++ Programming

A function is a code block that can be called from within another function (known as the calling function or simply the caller). When... more »
Copy constructors must accept an instance of an object. The instance can never be NULL, so we cannot pass a pointer. Even if the... more »

Top Questions

It depends whether the list is singly-linked or doubly-linked. Let's examine the case for...
The most efficient way to swap strings is to point at them, and swap the pointers....
The C and C++ implementation of sin(x) and cos(x) using Taylor's Series is...

Contributors

Top Contributors This Week

  • Trust Points: 2065
  • Member Since: 6/09
  • Trust Points: 2924
  • Member Since: 9/07
  • Trust Points: 67
  • Member Since: 11/12
  • Trust Points: 2941
  • Member Since: 10/10
  • Trust Points: 2333
  • Member Since: 3/09