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??

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

2061


Define C in your own Language.

644


cavium networks written test pattern ..

3600


Why is c not oop?

541


What does stand for?

601






Is fortran still used in 2018?

597


Is c pass by value or reference?

600


How are strings stored in c?

599


Why is not a pointer null after calling free?

600


How can I invoke another program (a standalone executable, or an operating system command) from within a c program?

656


What is wrong in this statement? scanf(ā€œ%dā€,whatnumber);

731


any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()

697


What is atoi and atof in c?

620


Write a program to find the biggest number of three numbers in c?

590


What is cohesion and coupling in c?

595