Source Code For you
Toggle navigation
Menu
Thursday, June 19, 2014
10:56 PM
zeentic
No comments
Sort number in C Source Code
This C program
sorts array in an ascending order.
Here is source code of the C program to sort the array in an ascending order. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/* * C program to accept N numbers and arrange them in an ascending order */ #include
void main() { int i, j, a, n, number[30]; printf("Enter the value of N \n"); scanf("%d", &n); printf("Enter the numbers \n"); for (i = 0; i < n; ++i) scanf("%d", &number[i]); for (i = 0; i < n; ++i) { for (j = i + 1; j < n; ++j) { if (number[i] > number[j]) { a = number[i]; number[i] = number[j]; number[j] = a; } } } printf("The numbers arranged in ascending order are given below \n"); for (i = 0; i < n; ++i) printf("%d\n", number[i]); }
Email This
BlogThis!
Share to X
Share to Facebook
Home
0 comments:
Post a Comment
Subscribe to:
Post Comments (Atom)
Unordered List
Sample Text
Blog Archive
▼
2014
(1)
▼
June
(1)
Sort number in C Source Code
About Me
zeentic
View my complete profile
Powered by
Blogger
.
Popular Posts
Sort number in C Source Code
This C program sorts array in an ascending order. Here is source code of the C program to sort the array in an ascending order. The...
Recent Posts
Text Widget
0 comments:
Post a Comment