Sunday, October 04, 2015

Write a program to take marks of 15 students and print them out in descending order of marks.

Solution:-
     #include<stdio.h>
     #include<conio.h>
     void main( )
     {
            int a[15],temp=0,i,j;
            clrscr( );
            printf("Enter the 15students marks : \n");
            for(i=0;i<15;i++)
            {
                      printf("\n Enter the mark %d \t",i+1);
                      scanf("%d",&a[i]);
             }
             for(i=0;i<15;i++)
             {
                      for(j=i+1;j<15;j++)
                      {
                                 if(a[i]<a[j])
                                 { 
                                           temp=a[i];
                                           a[i]=a[j];
                                           a[j]=temp;
                                  }
                       }
             }
             printf("\n The marks in desending order are : \n");
             for(i=0;i<15;i++)
             {
                        printf("%d \t",a[i]);
             }
             getch( );
     }