The placement session has begun in a college. There is N number of students standing outside an interview room in a line. It is given that the person who goes first has higher chances of selection.
Each student has a number associated with them representing their problem-solving capability. The higher the capability the higher the chances of selection. Now every student wants to know the number of students ahead of him with higher problem-solving capability.
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
/*
The placement session has begun in a college. There is N number of students standing outside
an interview room in a line. It is given that the person who goes first has higher chances of selection.
Each student has a number associated with them representing their problem-solving capability.
The higher the capability the higher the chances of selection.
Now every student wants to know the number of students ahead of him with higher problem-solving capability.
*/
int main()
{
int students[] = {4,3,5,7,2,12};
int counter;
for(int i=0; i<6; i++)
{
counter = 0;
for(int j=0; j<i; j++)
{
if (students[j] > students[i])
{
counter += 1;
}
}
printf("\n\tCount = %d",counter);
}
}
Comments
Leave a comment