Question was: Guys tell me how to print both 'if' and 'else' block in a program..
I gave following solution (But still wondering about the requirement?)
int main(void)
{
int a=2;
A:
a--;
if(a>0)
{
/* write ur code */
goto A;
}
else
{
/* write ur code */
}
return 0;
}
{
int a=2;
A:
a--;
if(a>0)
{
/* write ur code */
goto A;
}
else
{
/* write ur code */
}
return 0;
}
might it help ....
ReplyDelete#include
#include
int main()
{
int a ;
if(fork())
{
printf("in if \n");
}
else
{
printf("in else \n");
}
return 0 ;
}
yeah..But is not this writing two programs. What I understand is above program will be divided into two process (in two different address spaces where child will be having the copy of the parent's space).
ReplyDeleteAnd Fork will return 0 to child therefor, IF condition will fail for Child while it will pass for Parent. right?