Chars | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Chars

#include <iostream> using namespace std; int main() { char c; c='tuz'; cout<<c; return 0; } Output is z Why it stores the last character Its running completely

14th Jul 2018, 3:26 PM
Siddharth Jain
Siddharth Jain - avatar
1 Answer
+ 2
Siddharth Jain A char data type is meant to store a SINGLE character. so :: char c= 'tuz' is same as char c= 't', c='u', c= 'z'. c = 'z' is the last expression evaluated, so Char c ='z'
14th Jul 2018, 4:35 PM
Dlite
Dlite - avatar