Problem 12

author
By Supreme2023-02-23
Problem Statement :
Write a program to read marks from keyboard and your program should display equivalent grade according to following table(if else ladder)
Code:

#include <stdio.h>

int main()
{

// 12. Write a program to read marks from keyboard and your program
// should display equivalent grade according to following table(if else ladder)
// Marks Grade
// 100 - 80 Distinction
// 79 - 60 First Class
// 59 - 40 Second Class
//< 40 Fail

float marks;

printf("\tGrade Generator");
printf("\n==========================");

printf("\nEnter Your Marks : ");
scanf("%f", &marks);

printf("__________________________");

if (marks >= 80 && marks <= 100)
{
printf("\n\nDistinction");
}

else if (marks >= 60 && marks <= 79)
{
printf("\n\nFirst Class");
}

else if (marks >= 40 && marks <= 59)
{
printf("\n\nSecond Class");
}

else if (marks < 40)
{
printf("\n\nFail");
}

printf("\n__________________________\n\n");

return 0;
}

Description :
  • This code reads marks from the keyboard and generates the grade equivalent to the entered marks according to the given table using if-else ladder. If the marks are between 80 to 100, it prints "Distinction," if they are between 60 to 79, it prints "First Class," if they are between 40 to 59, it prints "Second Class," and if they are less than 40, it prints "Fail." Finally, it prints the message "Grade Generator" and displays the corresponding grade based on the entered marks.
Output Image:
Output-image

© Copyright 2022. All right reserved, GTU Coder.