SwitchFunc - cout <<...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
****************switch function*************************(instead of "if") switch(int exp) //ONLY AN INT! { case v1: Task1; break; case v2: Task2; break; : : default: TaskN; break; } -a character counts as int. .. i think? EXAMPLE: Grade = ???. ..; switch (Grade) { case 'a' : case 'A' :GPA = 4.0;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout << "Good Job" break; case 'b' : case 'B' :GPA = 3.0; break; case 'c' : case 'C' :GPA = 2.0; break; default :GPA = 0.0; break; } OR if the input is originally not an int: switch( (int) Avg) //casts the Avg value as an int...
View Full Document

This note was uploaded on 11/01/2009 for the course CS 101 at USC.

Ask a homework question - tutors are online