Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

why is the output for the followong program c=200?

–1 vote
asked Nov 8, 2018 by anonymous

int main()


  int a=300,b,c;





   return 0

; }

why is the output c=200?

2 Answers

0 votes
answered Nov 8, 2018 by Mark (140 points)
what is your program doing?
commented Nov 9, 2018 by krish
c == 200 is correct because c is out of scope in terms of if() construct. lets say,
   c=200;// c is inside if condition
but in your program u r initializing (actually) thinking that c is inside if
0 votes
answered Nov 9, 2018 by Toshi Mudgal (160 points)
because if statement executes the immediate next statement only if you want more than one statements to be executed use curly braces.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.