FirstNaukri
Home Search Jobs Govt JobsNew Resume Makernew Career Guidance Ask n Answer Student Ambassadors

Register|Login

  Ask n Answer
  Ask a Question
0 out of 300 characters

QUESTION
if(condition)
{
printf('hello');
}
else
{
printf('word');
}

for printing 'helloword' what condition should be write?
By shaila bhanudas k... (Beginner)  8 years ago   59 views
 
 Your Answer
0 out of 1250 character
 
 
 
Share |
Report Abuse
 
 
 
 
ANSWERS (3)
 
 
 
 
if(!printf('hello'))
{
printf('hello');
}
else
{
printf('word');
}

printf() returns non-zero value. So the condition will become false after printing hello. Then it will execute the else part and print word. So final output becomes helloword.
 
 
Amir Ashraf Aazmi Sorry Junaid, I didn't get you. What is the syntax error?
8 years ago
 
 
 
JUNAID ALI RESHI printf('word'); should be as printf('word'); and same applies to all strings here
8 years ago
 
 
 
JUNAID ALI RESHI I Guess this Naukri.com automatically converts double quotes into single.

printf(''word'');
8 years ago
 
 
 
JUNAID ALI RESHI ^ should be there instead of printf('word');
8 years ago
 
 
 
Amir Ashraf Aazmi Good catch. :)
8 years ago
 
 
 
 
Know a better answer? Click here to post.
 
 
Print helloword
 
 
 
Know a better answer? Click here to post.
 
 
If else is a conditional block.
at one time --only if OR else will work.
Therefore condition will determine which block will run.
 
 
 
Know a better answer? Click here to post.
 
 
 
 
 

Ask & Answer
Panel of Experts

 
 
 
 
 
All rights reserved © 2022 Info Edge (India) Ltd.