what is the output of the program??

#include<stdio.h>

main ( )

{

int a=010,sum=0,tracker:

for(tracker=0;tracker<=a;tracker++)

sum+=tracker;

printf(“ %d\n”,sum);

}

what is the difference between a=10 and a=010??

Answers were Sorted based on User's Feedback



what is the output of the program?? #include<stdio.h> main ( ) { int a=010,sum=0,t..

Answer / vidyullatha

In linux:
Answer is 36 instead of 55.
i.e the loop iterates till tracker=8 instead of tracker=10.
Thats is because, I guess when u initialise a=010, compiler
takes a = octal 10 i.e in decimal it is 8.
So the loop iterates through tracker<=8.
This is my guess. I am not sure of the real answer.
Please let me know if any one knows the right answer.

Is This Answer Correct ?    12 Yes 1 No

what is the output of the program?? #include<stdio.h> main ( ) { int a=010,sum=0,t..

Answer / xyz

near keyword int there is a colon so isnt tat a compling error

Is This Answer Correct ?    0 Yes 0 No

what is the output of the program?? #include<stdio.h> main ( ) { int a=010,sum=0,t..

Answer / manish

yes...
this is the case of memory mapping....

Is This Answer Correct ?    3 Yes 4 No

Post New Answer

More C Interview Questions

what is a far pointer

12 Answers   ABB, DRDO, ITI, Maruti Suzuki, Steel Plant, TCS, Toyota, Vivo Mobiles,


Can true be a variable name in c?

0 Answers  


What is the memory allocated by the following definition ? int (*x)[10];

4 Answers   ADITI, Wipro,


What is structure packing ?

2 Answers   HP,


write the function int countchtr(char string[],int ch);which returns the number of timesthe character ch appears in the string. for example the call countchtr("she lives in Newyork",'e') would return 3.

6 Answers  


What happens if you free a pointer twice?

0 Answers  


Can stdout be forced to print somewhere other than the screen?

0 Answers  


Explain how do I determine whether a character is numeric, alphabetic, and so on?

0 Answers  


How can I pad a string to a known length?

0 Answers  


What is the difference between break and continue?

3 Answers  


regarding the scope of the varibles;identify the incorrect statement: a.automatic variables are automatically initialised to 0 b.static variables are are automatically initialised to 0 c.the address of a register variable is not accessiable d.static variables cannot be initialised with any expression

1 Answers   TCS,


Write c-code for 5+55+555+5555+55555+555555+5555555. Output will be it's answer...

4 Answers   TCS,


Categories