You are here:   HomeC Programming (Theory)Control Structures in CWrite a C program to show working of continue.
by Dinesh Thakur Category: Control Structures

The program segment given below accepts marks in a single subject and uses a nested if statement to determine the validity of marks and the result if the value of marks is valid. This code can be written in a more readable form using an if-else-if statement as

#include <stdio.h>

void main()


     int marks;


    printf("Enter Marks of single subject  :\n");

    scanf ("%d", &marks);

    if (marks >= 0)


             if (marks <= 100)


                       if (marks >= 35)

                          printf("Result: Pass\n");

                          else printf("Result: Fail\n");


                 else printf("Error: Marks can't exceed 100\n");


                 else printf("Error: Marks can't be negative\n");



         C Program Examination result in a single subject with data validation

Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes 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.

What's New and Popular

Popular Article