- 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; }

1st Jun 2018, 5:49 AM
Abhisek Sao
2 Respostas
0
ook
1st Jun 2018, 8:48 AM
Abhisek Sao