Answers for "case c++"

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
2

how to make a switch case statement in c++

#include <iostream>
using namespace std;
int main(){
   int num = 5;
   switch(num + 2) {
      case 1: 
        cout << "Case1: Value is: " << num << endl;
      case 2: 
        cout << "Case2: Value is: " << num << endl;
      case 3: 
        cout << "Case3: Value is: " << num << endl;
      default: 
        cout << "Default: Value is: " << num << endl;
   }
   return 0;
}
Posted by: Guest on March-04-2020
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++ awitch statements

var = 1

switch (var):

  case 1:
	break; // Code that is executed if var is 1

  case 2:
	break; // Code that is executed if var is 2

  default:
	break; // Code that is executed if no cases match
Posted by: Guest on November-23-2020
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

C# Answers by Framework

Browse Popular Code Answers by Language