May be I'm going to ask a stupid question, but I want to confirm that how char works? Let me explain with examples what i want to ask.
Let suppose I declare a char variable
and then input 6
or any integer character.
#include <iostream>
using namespace std;
int main(){
char a;
cin >> a;
cout << a*a; // I know here input's ASCII value will multiply
return 0;
}
Same as for integer input 6
#include <iostream>
using namespace std;
int main(){
int a;
cin >> a;
cout << a*a; // Why compiler not take input's ASCII Value here?
return 0;
}
I think now my question is clear.