TCS
Company
Programming
Variables
Predict the output of following code:
main()
{
int a,x=2,3,4,5; // Error because list is not within ( )
a=1,2,3,4,5;
printf(“%d%d”,x,a);
}
1. Error
2. 5,1
3. 2,1
4. 5,5
Read Solution (Total 6)
-
- Answer is Error Because Declraction terminated is incorrectly.
- 5 years agoHelpfull: Yes(3) No(0)
- 3 option is the answer.
Each take first element as a value.
if it in a list , it takes the last element as the value. - 6 years agoHelpfull: Yes(1) No(1)
- i have run this code ,it is showing error
(udhaya answer is wrong) - 5 years agoHelpfull: Yes(1) No(0)
- (1) Error because the x values are not in a list
- 6 years agoHelpfull: Yes(0) No(0)
- option 1 is correct because in c this declaration is not allowed.
- 6 years agoHelpfull: Yes(0) No(0)
- Option 1.Error
- 5 years agoHelpfull: Yes(0) No(0)
TCS Other Question
Predict the output of following code:
main()
{
int a,x=(2,3,4,5); //valid statement x = last value in list
// x = 5 during declaration list
should be specified inside ( )
a=1,2,3,4,5; // valid; a = 1; first value of the list is
assigned to variable
printf(“%d%d”,x,a);
}
1. Error
2. 5,1
3. 2,1
4. 5,5
Predict the output of following code:
main()
{
int x=10,y=-10;
printf(“%x t”,x<>2);
}
1. 28 fffd
2. 40 -3
3. Error
4. 0,1