/*calculate percentile of student...i did hardcode
we can get the value at run time using input fucntion*/
#include<iostream.h>
using namespace std;
int main()
{
 //a[0]=first candidate and so on
    int a[]={25,60,80,70,26},n=5,i,j;//n=no. of candidate
    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); 
               cout << "\n the percentile of " << " a ["<<i<<"] " << percent ;
} } //End of main /*OUTPUT:- 1-the percentile ofa[0]0
2-the percentile ofa[1]50 
3-the percentile ofa[2]100 
4-the percentile ofa[3]75 
5-the percentile ofa[4]25
*/
*/
No comments:
Post a Comment