TCS
Company
Programming
Definition
What is the output of:
#include
int main()
{
int x=40;
{
int x=20;
printf("%d",x);
}
printf("%d",x);
return 0;
}
Read Solution (Total 9)
-
- Output : 20, 40
x = 20 is declared inside a block...
so that can be accessed in that block only...
Outside that block x = 40...
- 10 years agoHelpfull: Yes(14) No(1)
- INT X=40, IS A GLOBAL DECLARATION BUT AS LOCAL VARIABLE HAS HIGHER PRECEDENCE THAN
GLOBAL,THEREFORE X=20,X=40 WHICH IS GLOBAL...... - 10 years agoHelpfull: Yes(3) No(0)
- 20
40
first the local variable x will be printed followed by global variable x - 5 years agoHelpfull: Yes(0) No(0)
- 20 40
20 is in braket so it will get printed first .after that 40. - 4 years agoHelpfull: Yes(0) No(0)
- 40 20 scope of their brackets
- 3 years agoHelpfull: Yes(0) No(1)
- 20 will ne the output
- 2 years agoHelpfull: Yes(0) No(0)
- Output :20 ,40
- 1 year agoHelpfull: Yes(0) No(0)
- it shows error: header file not there
- 1 year agoHelpfull: Yes(0) No(0)
- answer is 2040
- 6 Months agoHelpfull: Yes(0) No(0)
TCS Other Question