I'm not sure if this will work. I'm assuming it should , I just can't figure out how.
I am trying to execute a Switch case from the result from an If Statement. For example if the result from the If is 1 , the first case executes
This is what I'm thinking:
#include <iostream>
using namespace std;
int main(){
int opt;
char input;
cout<<"Enter something: ";
cin> >input;
if (input >=48 && input<=57){
opt= 1;
}
switch(opt){
case 1:
cout<<"You have inputted a digit";
break;
}
return 0;
}
Is what I'm thinking possible?
Aucun commentaire:
Enregistrer un commentaire