Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ switch integer

int testScore;                     
    cout <<"Enter your test score and I will tell you 
";
    cout <<"the letter grade you earned ";
    cin >> testScore;

    switch(testScore/10)
{ 
    case 10:
    case 9:
        cout <<"Your grade is A.
";
    break;
    case 8: 
        cout <<"Your grade is B.
";
    break;
    case 7: 
        cout <<"Your grade is C.
";
        break;
    case 6: 
            cout << "Your grade is D.
";
        break;
    case 5: 
            cout << "Your grade is F.
";
        break;

    default:
        cout << "That score isn’t valid
";

    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #switch #integer
ADD COMMENT
Topic
Name
6+9 =