by Dinesh Thakur Category: Control Structures

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)

printf("Pass\n");

else printf("Fail\n");

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)

printf("Fail\n");

else printf("Pass\n");

Example: Find the Result of a student in SSC Examination

 

#include <stdio.h>

void main()

{

        int m1,m2,m3,m4,m5,m6;

        clrscr();

        printf("Enter the Marks :\n");

        scanf("%d%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5,&m6);

        if (m1 >= 35 && m2 >= 35 && m3 >= 35 && m4 >=35 && m5>=52 && m6>=52)

        printf("Pass\n");

        else printf("Fail\n");

         getch();

}

      C Program Find the Result of a student in SSC Examination



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles