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
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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.
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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.
...