+ 3
How to execute both conditions of if else Statement
I want to execute both conditions of if else statement . for example I want to print 12 as the output of the following program. if(x) cout<<1; else cout<<2;
6 Respuestas
+ 3
I heard both conditions may get executed
+ 3
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
if (!(printf("1")))
;
else
printf("2");
getch();
}
//we all know that printf(), scanf(), exit() returns zero hence by adding ! It makes the value false so it prints if statement as well as else statement and the symbol ; terminates the statement :3
/*now apply this trick with all ur frnds n njoy*/ ;)
The code is being fully tested and this is how the output looks like with both if and else statement
+ 1
if(x) is true, so this code will only execute cout<<1, remove the else and your done.
0
if.. else... cannot execute both brackets. if and only if 'IF' is false then it goes to ELSE.
0
Remove if-else.
Otherwise, only one flow will be executed according to condition.
0
you can use if elseif statement