Tuesday 17 April 2012

C program to calculate percentile of student array



/*calculate percentile of student...i used predefined numbers and students
we can take value from user at run time  also using input fucntion*/



#include<stdio.h>
int main() 
 {
       //a[0]=obtain marks of first student 
      int a[]={25,60,80,70,26} ; 
      int n=5 ;
      int i,j ;
     //n=no. of student int percent; int count; 
        for( i=0;i<=n-1;i++) 
           { 
                count=0; 
                for(j=0;j<=n-1;j++)
                  { 
                      if(a[i]>a[j]) 
                        { 
                           count=count+1; 
                        } 
                  } 
                percent = (count * 100) / (n-1) ; //logic to calculate percentile

                printf( "\n the percentile of a[%d] is %d", i, percent) ;
            } 
 } //end of main



No comments:

Post a Comment

Compiler for C,C++ and Python {paste your programme to see the output}