0

can numbers ( 1, 2, 13, 25 ... ) be char data types ?

19th Jul 2016, 10:14 PM
Peter Müller
Peter Müller - avatar
4 ответов
+ 3
yes, char myChars =['1','2','3','4'}; alternatively if you say something like char ch = 97; cout << ch; will print a, and not 97 since 97 is the ascii code for a
19th Jul 2016, 10:17 PM
destro
+ 2
as an addition of destro's answer remember range of char = -128 to 127 unsigned char = 0 to 255
20th Jul 2016, 2:25 PM
Mukul Kumar
Mukul Kumar - avatar
0
}else if(y != 1 && y != 0){ cout << "error" << endl; return 0; } now y is an int type and if user types a it always takes it as 0 can i set y to char type and the user can text xyz or a number like 23 and it will cout error ?
19th Jul 2016, 10:22 PM
Peter Müller
Peter Müller - avatar
0
unsigned int or int data type..
20th Jul 2016, 3:03 AM
meherDev
meherDev - avatar