#include<stdio.h>
//#include<conio.h>
void main() {
int a[10], i, j, temp = 0, no;
//clrscr();
printf("Enter the no of elements in the array:\n");
scanf("%d", &no);
printf("Enter the array a:\n");
for (i = 0; i < no; i++)
scanf("%d", &a[i]);
for (i = 0; i < no; i++) {
for (j = i + 1; j < no; j++) {
if (a[i] > a[j]) {
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
printf("The Ascending array:\n");
for (i = 0; i < no; i++)
printf("%d\n", a[i]);
//getch();
}
Note: Remove the comment line when you are use Turbo C IDE for run your program.
Monday, 5 October 2015
Write a program to given numbers in ascending order.
Labels:
C,
GTU Practical
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment