- 1
How to add maximum 5 numbers after arranging 8 or more numbers in for loop in C in descending order?
#include <stdio.h> int main() { float n[100],b; int a,i,j; scanf ("%d",&a); for (i=0;i<a;i++) { scanf ("%f",&n[i]); } for (i=0;i<a;i++) { for (j=i+1;j<a;j++) { if (n[i]<n[j]) { b=n[i]; n[i]=n[j]; n[j]=b; } } } printf ("The numbers in decending order: "); for (i=0;i<a;i++) { printf ("%f\n",n[i]); } return 0; }
2 Antworten
0
ook