There are N coding questions and the score for Ith question must be in the range of 1 to N(inclusive). All the coding questions follow one rule that higher the score higher is difficulty level. Now Tom is trying to assign the score to each question in a sorted difficulty order such that 1st question is of least difficulty level and Nth question is of most difficulty level. And it is also possible that more than one question can have equal score.
#include<stdio.h>
#include<conio.h>
int main(){
int question;
int questions[];
printf(''Enter the number of questions:'');
scanf(''%d'',&question);
printf(''Enter the rating of questions:'');
for(int i=0;i<question;i++){
scanf(''%d'',&questions[i]);
}
int temp;
for(int i=0;i<questions.length;i++){
for(int j=i+1; j<questions.length;j++){
if(questions[i]<questions[j]){
temp=questions[i];
questions[i]=questions[j];
questions[j]=temp;
}
}
}
printf(''Questions with their shorted order is listed below :'');
for(int i=0;i<questions.length;i++){
printf(''%d'',questions[i]);
}
return 0;}
Comments
Leave a comment