Consider that we wish to determine the result of a student in the SSC (Secondary School Certificate) examination, which has six subjects: four of 100 marks each and two of 150 marks each.
For a student to pass the examination, he/she has to pass each subject, where the pass percentage is 35. Let us use variables ml, m2, m3, m4, m5 and m6 for marks in these subjects where the first four variables (ml to m4) represent marks in subjects having maximum 100 marks. The if statement given below determines the result of a student.
if (ml >= 35 && m2 >= 35 && m3 >= 35 && m4 >=35 && m5>=52 && m6>=52)
Alternatively, a student fails if he fails in any one of the subjects. Thus, the above if statement can be written as shown below.
if (ml < 35 || m2 < 35 || m3 < 35 || m4 < 35 || m5 < 52 || m6 < 52)
Example: Find the Result of a student in SSC Examination
printf("Enter the Marks :\n");
if (m1 >= 35 && m2 >= 35 && m3 >= 35 && m4 >=35 && m5>=52 && m6>=52)