Hi Friends..,
I m new to this forum as well as C. Is it possible to execute both If... & Else... at the same time? Thanks in advance.
With Regards,
Anandhakumar
|
Go4Expert Member
|
|
| 8May2008,04:12 | #2 |
|
That's not the point of if-else statements, so I don't know why you'd want to do it...
But if you want to get technical, I don't think it is possible. If you were really set on it, you could maybe nest an if-else statement, I guess. |
|
Go4Expert Founder
|
![]() |
| 8May2008,08:54 | #3 |
|
Use goto. From if's last statement jump to a statement using goto.
|
|
Banned
|
|
| 6Oct2009,19:09 | #4 |
|
but sir , using of Goto is not a good sort of coding for a problem..........
![]()
|
|
Go4Expert Founder
|
![]() |
| 6Oct2009,20:23 | #5 |
|
Then do not try stuff like executing if and else. They also could not be considered good
|
|
Mentor
|
![]() |
| 7Oct2009,00:30 | #6 |
|
No, you can't, because the whole point of if/else is to do one thing if an expression is TRUE and another if the expression is FALSE. If you want to execute both blocks of code then you need to rejig the expression, for example instead of
Code:
if (test) { ... }
else { ... }
Code:
if (test) { ... }
if (!test) { ... }
Code:
if (test || do_both) { ... }
if (!test || do_both) { ... }
|
|
Banned
|
|
| 7Oct2009,08:25 | #7 |
|
that's also correct sir.....
![]() ![]()
|
|
Newbie Member
|
|
| 13Aug2010,11:24 | #8 |
|
#include<stdio.h>
#include<unistd.h> int main() { pid_t pid; pid = fork(); if(pid==0) { printf("\nIF IS RUNNING\n"); } else { printf("\nELSE IS RUNNING\n"); } return 0; } |
|
Contributor
|
|
| 15Apr2011,17:08 | #9 |
|
yes i think i remember there is a code exist for it though i don't remember the code now
There is not any logical explanation for it but i think this code is a part of class room teaching in indian colleges. teachers consider this question as sacred you can find this question in every year question paper of our college. |




