+ 4
If statement if(???){ Printf("hello");}else{printf("world");} wht is the condition and output is :hello world
condition???
7 Réponses
+ 7
!(printf("hello "))
by putting this in condition we get the output as Hello world... bcz while condition is getting chckd it prints hello and as the condition is false so world will also get print hnce hello world is printed...
+ 5
@Pandey: Not bad. I guess it's my fault for interpreting the question as "Run both the if and the else blocks in one go".
+ 4
when if statement works else cannot be used so this is not possible
+ 3
Lara is right, if your if is executed only once, you will either execute the if block or the else block, depending on whether the condition is true or not.
If your if is executed several times however, it becomes possible.
for (int i = 0; i < 2; i++) {
if (i == 0) {
printf("Hello ");
} else {
printf("world\n");
}
}
+ 2
I'm sure that 100% possible #Lara
+ 2
#pandey
I expect this answer only ..........
thanks
All the best!
+ 1
#zen your answer also absolutely correct but without for loop only condition enough to display both blocks ...try this easy only