Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
What will be the result of the following code?
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
sushantvs
New Member
Join Date:
Dec 2010
Posts:
1
#1
What will be the result of the following code?
Dec 28 '10, 08:20 AM
int x = 3;
if (2 > x) print("First");
else
print("Second") ;
if (2 > x)
print("Third");
print("Fourth") ;
print("Fifth");
Rabbit
Recognized Expert
MVP
Join Date:
Jan 2007
Posts:
12517
#2
Dec 28 '10, 08:54 AM
Compile it and you will have your answer.
Comment
Post
Cancel
Shafi hashmi
New Member
Join Date:
Dec 2010
Posts:
14
#3
Dec 28 '10, 01:44 PM
The output will be
second
fourth
fifth
coz 2 is not greater than 3 hence else part will b printed. Again 2 is not greater than 3 hence next line will not be printed but next lines will be prnted coz they are not in the 'if' block
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment