1.
if(1)
printf("if loop");
else;
printf(" else loop");output:
if loop else loop
In the above statement note that there is a semi-colon (;) in the else statement. This statement is called as NULL statement in 'C'.
The above program becomes:
if(1)
printf("if loop");
else
;
printf(" else loop");;
2.
if(printf("if")==0)
printf(" if");
else
printf(" else");
output:
In the statement-2, the printf which is inside the if condition is executed. Generally if executes the statement which is given as condition, so executes the print statement and then checks it is equal to 0, here condition becomes false. When condition comes false else is executed.
if(condition)
printf("Hello");
else
printf(" world");
write the condition such that your output will be:
Hello world
sorry friend there is no way to execute if else both simultaneously.there are some trick to make full u by giving same output.
ReplyDeleteif(printf("if")==0)
ReplyDelete##printf(" if");
else
printf(" else");
In this case out put will be if else but ##printf want execute the printf which inside if will execute.
Why not this one:
ReplyDeleteif ( fork() ) {
print "hello";
}
else {
print "world";
}
#include
ReplyDeleteint main(){
if(fork())
{
printf("hello");
}
else
{
printf("world");
}
}
Its nt work...it show that frok has some prototype...wil u knw plz ensure it ..
Delete//Both Execute IF else in java
ReplyDeletepublic class Test12 {
public static int i=1;
public static boolean foo() {
boolean bl;
if(i==1)
{
bl= true;
}
else
{
bl= false;
}
return bl;
}
public static void main(String[] args) {
boolean bl;
for (int i = 1; i <=2; i++) {
bl=foo();
if(bl)
{
System.out.print("ChimanBhai");
Test12.i=2;
foo();
continue;
}
else
{
System.out.println(" Patel");
}
}
}
}
void main()
ReplyDelete{
int a=1;
if(a==1)
{
printf("hello");
if(a==1)
goto b;
}
else
{
b:printf("world");
}
}
if(1
ReplyDelete#define else if(1)
)
printf("if");
else
printf(" else");
int main()
ReplyDelete{
if(printf("i")<0)
printf("i ");
else
printf(" love");
return 0;
}
This comment has been removed by the author.
ReplyDeleteIf(!printf("hello")
ReplyDelete{
Printf("hello");
}
else
{
Printf("world");
}
I think it get execute