Question discussion

What will be printed by the following code?

358837Medium DSSSB TGT Computer Science 0 replies 0 views
0
What will be printed by the following code?
#include<stdio.h>
int main() {
    int marks = 75;
    char grade = (marks >= 90) ? 'A' : (marks >= 70) ? 'B' : 'C';
    printf("%c", grade);
    return 0;
}
  • AB
  • BCompile time error
  • CA
  • DC
Correct answer: A

Explanation

marks = 75 is not ≥ 90, but it is ≥ 70, so grade = 'B'.

Discussion 0

Nobody has replied yet. Start the discussion!