See what questions your friends are asking today.

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

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!!!

Contributors

Lagangkenneth
Trust: 2
  • Answered Most Recently

Top Contributors This Week

  • Trust Points: 2704
  • Member Since: 3/09
  • Trust Points: 10057
  • Member Since: 11/09
  • Trust Points: 2552
  • Member Since: 12/10
  • Trust Points: 3783
  • Member Since: 10/10
  • Trust Points: 4836
  • Member Since: 1/12