TCS Company Programming

Predict the output of following code:
main()
{
int sum;
char ch1='a';
char ch2='b';sum=ch1+ch2; // ascii sum; sum = 97+98 = 195
printf(“%d”,sum);
}

1. Error
2. 195
3. 201
4. “ab”

Read Solution (Total 4)

TCS Other Question

Predict the output of following code:
main()
{
int a=b=c=d=10;
//​ error: ‘b’ , ‘c’, ‘d’ undeclared
printf(“%d,%d,%d,%d”,a,b,c,d);
}
1. Error
2. 10,10,10,10
3. GV,GV,GV,10
4. GV,GV,GV,GV
Predict the output of following code:
main()
{
float a=1.1;
double b=1.1;
if(a==b) // datatype is different cant be compared; hence result will be 0
printf(“equal”);
else
printf(“not equal”);
}

1. ​ equal
2. not equal
3. Error
4. equal not equal