C Program to Display Student Results

The program to display student results demonstrate the use of conditional statements in C programming language. This program is intended for beginner level learners of C programming.

This program is written using Dev-C++ compiler installed on Windows 7 64-bit system. There are no other requirements to run this program, other than compiling the source code.

In this article, we have following sections – problem definition, flowchart, program source code and verified output to help you learn C programming efficiently.

Problem Definition

The C conditional statement can change the direction of the program based on the given inputs. There are many kinds of conditional statements, but if-else statements is most common and popular conditional statement.

This program reads the student marks ( in % ) and checks the condition for the results – Pass or Fail.

  1. First, we receive student marks in Percentage(%) as input to the program.
  2. Second, we check if the given percentage of marks is above or below 40%.
  3. If below 40%, then the student has failed.
  4. Else the student has passed.
  5. Display the result.

Flowchart – Program to Display Student Results

The flowchart for program to display student result is given below. The program start at the top and terminates where it says: End.

Flowchart - C Program to Display Student Results
Flowchart – C Program to Display Student Results

Program Code – Program to Display Student Results

The program source code for displaying student result is given below. If you decide to use another compiler than Dec-C++, you may have to tweak the code according to the recommendation of the new compiler.

/*Show result of student using Marks */


#include <stdio.h>
#include <conio.h>
int main()
{

    int marks,i;

    /* Read student marks */

    printf("Enter the marks (in percentage ) of Student:");

    scanf("%d",&marks);

    /* display result */

    if(marks < 40)
    {
        for(i=0;i<40;i++)
        printf("_");printf("\n\n");

        printf("Result = Failed\n");

        for(i=0;i<40;i++)
        printf("_");printf("\n\n");
    }
    else
    {
        for(i=0;i<40;i++)
        printf("_");printf("\n\n");

        printf("Result = Passed\n");

        for(i=0;i<40;i++)
        printf("_");printf("\n\n");
    }
    system("pause");
    return 0;
}

Output

The output of the program is shown in the following image. When the student enters his marks in percentage, the program calculate whether he has met the required criteria for passing the exam and then display the results.

Output - C Program to Display Student Grade
Output – C Program to Display Student Grade
Advertisements