Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Question 3

// To convert switch statement into if statement.
#include <stdio.h>
    int main(void) {
    int score;
    char grade;
    
    printf("Enter score: ");
    scanf("%d", &score);
    
    switch (score) {
        case 10: printf("case 10\n");
        case 9: printf("case 9\n");
        case 8: grade = 'A'; break;
        case 7: printf("case 7\n");
        case 6: grade = 'B'; break;
        case 5: grade = 'C'; break;
        default: grade = 'F';
    }
    
    printf("Grade is %c.\n", grade);
    return 0;
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.