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

Find Error if any in below code, Justify ur answer: struct xx { int a; struct yy { char c; struct xx* p; } struct yy* q; }

3 Answers   NDS,


What is your stream meaning?

0 Answers  


What are register variables in c?

0 Answers  


What is omp_num_threads?

0 Answers  


Is that possible to store 32768 in an int data type variable?

0 Answers  






how to add our own function in c library please give details.?

1 Answers   TCS,


What is the difference between new and malloc functions?

0 Answers   InterGraph,


Explain how do you override a defined macro?

0 Answers  


what do you mean by defining a variable in our c code?

2 Answers  


Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?

0 Answers   TCS,


What are the 4 types of functions?

0 Answers  


What is an array in c?

0 Answers  


Categories