0

when we use char x ; then input x=97 what is the output??

25th Oct 2016, 5:43 AM
gharam saad
9 Réponses
+ 2
Reminder: "You are wrong" is not a proof. This should settle the discussion: http://www.sololearn.com/app/sololearn/playground/cyr7Db1cd4Vi/ #include <iostream> using namespace std; int main() { char x = 97; cout << x << endl; //prints a x = '97'; cout << x << endl; //prints 7 char *y = "97"; cout << *y << endl; //prints 9 return 0; }
25th Oct 2016, 9:24 AM
Zen
Zen - avatar
0
a
25th Oct 2016, 5:54 AM
Muhammed Thahir
Muhammed Thahir - avatar
0
OK when x='97' why the answer is 7 ?? not 9
25th Oct 2016, 6:42 AM
gharam saad
0
'97' will give you a compile error...
25th Oct 2016, 7:38 AM
bleh990
0
@marcram, you are wrong. please be Sure before give wrong answers and downvote others...
25th Oct 2016, 7:56 AM
bleh990
0
@zen, it is not a proof, but you are right 😀... ...and I am right too... 😀
25th Oct 2016, 9:32 AM
marcram
- 1
if x=97 the output is "a" if x='97' it depends on the compiler, probably the output is "7" because it use the last character.
25th Oct 2016, 7:34 AM
marcram
- 1
@bleh990, NO, '97' doesn't give you a compiler error. It may give you a warning, but the program works and give "7" as result. Please, be sure before give wrong answers and downvote other answers...
25th Oct 2016, 7:53 AM
marcram
- 1
@bleh990, I have just tried to compile, and it works. Everyone can try, the code is very simple. And if you google it, you can find answer similar to mine. So YOU are wrong.
25th Oct 2016, 8:04 AM
marcram