+ 1
Plz explain 7th line of code and hence the output?
c++ challenge question. https://code.sololearn.com/cu43n6fXgk38/?ref=app
5 Respostas
+ 4
gaurav kumar
Actually here ASCII value is subtracting not character
A character can assign to int data type but when you print that you get ASCII value.
Try this:
int a = 'a';
cout << a;
+ 3
gaurav kumar
c = s[3] = a
On line number 7 there is ++c so now c would be b as it is increasing ASCII value of a so next character is b
++c = b
Now s[1] is b so a would be 0
+ 3
gaurav kumar
ASCII value of a = 97
ASCII value of b = 98
So here ++c would be 98 but c is a char so it will print b
if you do
int a = 'a' then you will get cout << a; as 97
+ 2
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ plz tell how we can subtract two characters.
0
char is an integer data type, we can subtract them.
in your example:
++c = s[1] = 'b'
a = ++c-s[1] = 'b' - 'b' = 98 - 98 = 0