Answers for "c++ using case"

C++
1

how to use a case loop in c++

int x = 0;
int y = 4;
int g = 0;

switch(x) {
  	case y: // if x == y then run:
    // your code (0 != 4, this code wont run)
	break;
    
  	case g: // if g == y then run:
    // your code (0 = 0, this code will run)
    break;
    
  	default: // if none of the conditions above are met, run this:
    // your code (this is skiped, because a diferent case has been met.
    break;
}
Posted by: Guest on October-17-2021
0

switch case c++

// Transfers control to one of the several statements, depending on the 
//value of a condition.
switch (variable or an integer expression) {
     case constant: {
     	//C++ code
    	 break;
     }
     case constant: {
     	//C++ code
     	break;
     }
     default: {
     	//C++ code
     	break;
   	 }
}
Posted by: Guest on April-30-2021
0

c++ switch case

switch(expr) {
  case 1:
    // do something
    break;
  case 2:
    // do something
    break;
  default:
    // do something
}
Posted by: Guest on January-03-2021

Browse Popular Code Answers by Language