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.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
why is the output for the followong program c=200?
–1
vote
asked
Nov 8, 2018
by
anonymous
#include<stdio.h>
int main()
{
int a=300,b,c;
if(a>=400)
b=300;
c=200;
printf("%d%d",b,c);
return 0
; }
why is the output c=200?
please-help
Please
log in
or register to answer this question.
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,
if(a>=400)
{
b=300;
c=200;// c is inside if condition
}
but in your program u r initializing (actually) thinking that c is inside if
Please
log in
or register to add a comment.
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.
Please
log in
or register to add a comment.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...