From 1387ae8b972468e731229052c6923fb02cbb1e39 Mon Sep 17 00:00:00 2001 From: Shri Hari Tiwari <72088677+haritiwari4@users.noreply.github.com> Date: Tue, 8 Jun 2021 10:14:46 +0530 Subject: [PATCH] Update m1-t9-e4.c I updated the code becouse the last code doesn't run properly on Eclipse IDE --- .../m1-code-challenges-solution/m1-t9-e4.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/m1-getting-started-with-programming-in-c/m1-code-challenges-solution/m1-t9-e4.c b/m1-getting-started-with-programming-in-c/m1-code-challenges-solution/m1-t9-e4.c index 4fa0c64..63c99c1 100644 --- a/m1-getting-started-with-programming-in-c/m1-code-challenges-solution/m1-t9-e4.c +++ b/m1-getting-started-with-programming-in-c/m1-code-challenges-solution/m1-t9-e4.c @@ -5,9 +5,10 @@ int main() { // WAP to find out the grade of a student based on marks secured in the exam. // Code challenge solution - char grade = ‘X’; + char grade = 'X'; int marks; puts("Please enter your marks: "); + fflush(stdout); scanf("%d", &marks); if (marks >= 450 && marks <=500) { @@ -25,11 +26,10 @@ int main() { } else { // For negative value or a value greater than 500 puts("Invalid input."); } - -/* If the marks entered by the user is a valid mark between 0 and 500 then ‘grade’ would not be equal to ‘X’ i.e. he has been assigned a valid grade. */ - if (grade != ‘X’) + +/* If the marks entered by the user is a valid mark between 0 and 500 then ‘grade’ would not be equal to ‘X’ i.e. he has been assigned a valid grade. */ + if (grade != 'X') printf("\nYour grade is: %c", grade); return 0; } -