Problem Description
The PDD teacher wants to know number of students got fail mark in CT I if she has a unordered list of marks for 10 students
Test Case 1
Input (stdin)Thomas 75
Imran 60
Sithik 80
Setan 80
Milton 85
Arjun 42
Rakesh 91
Hrithik 88
Ayush 85
Aswathy 55
Expected OutputNumber of the student got fail marks 1
Test Case 2
Input (stdin)Thomas 75
Imran 60
Sithik 80
Setan 80
Milton 85
Arjun 85
Rakesh 91
Hrithik 88
Ayush 85
Aswathy 55
Expected OutputNumber of the student got fail marks 0
#include <stdio.h> int main() { int a[10],count=0,i; char k[10]; for(i=0;i<10;i++) {scanf("%s",k); scanf("%d",&a[i]); if(a[i]<50) { count++; } } printf("Number of the student got fail marks %d",count); return 0; }
Here's a brief explanation of how the code works:
Input Handling:
The program is designed to process the marks of 10 students. For each student, the program reads the student's name (stored ink
) and their corresponding mark (stored ina[i]
).Count Failures:
As each student's mark is input, the program checks if the mark is less than 50, which is considered a failing mark. If the mark is less than 50, thecount
variable is incremented by 1.Output the Result:
After processing all 10 students, the program prints the total number of students who received failing marks. The result is displayed in the format: "Number of the student got fail marks X", whereX
is the count of failing students.Loop Through All Students:
The loop runs 10 times, once for each student, ensuring that every student's marks are checked.
Summary: The program counts how many students received a failing mark (less than 50) from a list of 10 students and then outputs that count.