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

How to avoid structure padding in C?

8 Answers   Tech Mahindra,


What do you mean by c what are the main characteristics of c language?

0 Answers  


give one ip, find out which contry

4 Answers   Google,


Why we use conio h in c?

0 Answers  


1,4,8,13,21,30,36,45,54,63,73,?,?.

10 Answers   AMB, Franklin Templeton,






What is Function Pointer? Explain with example?

3 Answers  


What is a function simple definition?

0 Answers  


Explain what happens if you free a pointer twice?

0 Answers  


what does ‘segmentation violation’ mean?

1 Answers  


What is meant by high-order and low-order bytes?

0 Answers  


What is declaration and definition in c?

0 Answers  


Discuss the function of conditional operator, size of operator and comma operator with examples.

0 Answers   TCS,


Categories