NVIDIA Interview Question
hey Switch Can Only accept int or char
not string
test this program to confirm
#include <iostream>
#include <string>
using namespace std;
int main (void)
{
char word;
cout<< "Enter word to define: \n";
word = getchar();
switch (word){
case 'd':
cout<< "A four legged animal";
break;
case 'c':
cout<< "A animal scared of water";
break;
default:
cout<< "not in dictionary";
}
return 0;
}
float and string
- Anonymous November 03, 2009