Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Thursday, March 11, 2010

Input 20 numbers. Arrange the numbers in descending order and display descending order. (Sorting of an array)

Write a program in C accept 20 integers and arrange them in the descending order of values.(Sorting of an array)


#include<stdio.h>
#define N 20
void main( )
{
int i, j, n[N], t;
printf("Enter %d integer values\n", N);
for (i=0; i < N; i++)
scanf("%d", &n[i]);
for(i=0; i < N-1; i++)
for (j=i+1; j < N; j++)
if (n[i] < n[j])
{
t = n[i];
n[i] = n[j];
n[j] = t;
}
printf("The descending order is \n");
for (i=0; i < N; i++)
printf("%d\t", n[i]);
getch( );
}

Related Posts by Categories



0 comments:

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP