TCS Company Programming Basics

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

Read Solution (Total 10)

TCS Other Question

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”
What is the output for following?
main()
{
printf(“%%%%”);
}

1. %%%%
2. %%
3. Error
4. Garbage Value