C Program if else : "Simple Marksheet using if else" with output
#include <stdio.h>
int main() { float marks; // Input the marks printf("Enter the marks: "); scanf("%f", &marks); // Check and assign the grade char grade; if (marks >= 90) { grade = 'A'; } else if (marks >= 80) { grade = 'B'; } else if (marks >= 70) { grade = 'C'; } else if (marks >= 60) { grade = 'D'; } else { grade = 'F'; } // Display the marksheet printf("Marks: %.2f\n", marks); printf("Grade: %c\n", grade); return 0; }Enter the marks: 85.5
Marks: 85.50
Grade: B
Comments
Post a Comment