C PROGRAM
C program to print the values in descending order#include <stdio.h> #include<conio.h> void main() { int a[30],n,temp,i,j; clrscr(); printf("enter the values of N \n"); scanf("%d",&n); printf("enter the numbers \n"); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(a[i]<a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } } printf("the number is arranged in descending order \n"); for(i=0;i<n;i++) { printf("%d \n",a[i]); } getch(); }
OUTPUT: enter the values of N 4 enter the numbers 20 90 80 56 the number is arranged in descending order 90 80 56 20 Process finished.
|
No comments:
Post a Comment