Hi I want to know what happens if you declare a and b as an integer, but you assign a character value to it. For example A is declared as an integer, but you assign '5' to it. What will be the answer? Can someone explain to me what is the value of 'ans' in the following few scenarios and how did you arrive to it? Thanks in advance!
int main()
{
int a,b;
char ans;
a = '5';
b = '7';
ans = a * b;
cout << ans;
return 0;
}
int main()
{
char a,b;
char ans;
a = '5';
b = '7';
ans = a * b;
cout << ans;
return 0;
}
int main()
{
int a,b;
int ans;
a = '5';
b = '7';
ans = a + b;
cout << ans;
return 0;
}
int main()
{
char a,b;
int ans;
a = 5;
b = 7;
ans = a * b;
cout << ans;
return 0;
}
int main()
{
char a;
int ans, b;
a = 5;
b = 7;
ans = a * b;
cout << ans;
return 0;
}