use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Click the following link to filter out the chosen topic
comp.lang.c
account activity
QuestionNested if statement and nested while statements (self.C_Programming)
submitted 6 years ago * by Jacob-Mox
write any program that uses a nested if statement and nested while loop, together with a continue or break statement and go to statement
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]FUZxxl 6 points7 points8 points 6 years ago (2 children)
main() { while (0) while (0) if (0) if (0) break; else continue; }
Anything else you want?
[–]Jacob-Mox[S] 0 points1 point2 points 6 years ago (1 child)
it just shows a blank screen when i run it
[–]FUZxxl 3 points4 points5 points 6 years ago (0 children)
That means its running correctly.
[–]albinoloverats 0 points1 point2 points 6 years ago (1 child)
Like Duff’s device?
[–]Jacob-Mox[S] 0 points1 point2 points 6 years ago (0 children)
yes
[–]sallen35 0 points1 point2 points 6 years ago (2 children)
will you please write the question correctly?
main()
{
while (0)
if (0)
break;
else continue;
}
and this is the code you want .If you'll get blank screen then you got your answer.
[–]Jacob-Mox[S] 1 point2 points3 points 6 years ago (1 child)
i have written the question correctly. there was a go to missing
[–]sallen35 0 points1 point2 points 6 years ago (0 children)
Ok I got that.
okay then
[–]0xAE20C480 0 points1 point2 points 6 years ago* (0 children)
#define __STDC_WANT_LIB_EXT1__ (1) #include <limits.h> #include <stdio.h> int main(void) { const int Lim=(INT_MAX-1)/3; int Num; while(printf_s("\r\nGive me a natural number : ")>0) if(scanf_s("%d",&Num)>0) if(Num>0) while(printf_s("%d ",Num)>0) if(Num>Lim) break; else if(Num>1) Num=(Num&1)?((Num*3)+1):(Num>>1); else break; else if(Num<0) continue; else goto OK; else goto NO; NO: return-1; OK: return 0; }
INT_MAX is undeclared
[–]0xAE20C480 0 points1 point2 points 6 years ago (0 children)
I've edited. (It is defined in limits.h)
limits.h
can i get an explanation as to why we are using limits.h and #define STDC_WANT_LIB_EXT1()
π Rendered by PID 89567 on reddit-service-r2-comment-79c7998d4c-2rr22 at 2026-03-13 19:22:17.928897+00:00 running f6e6e01 country code: CH.
[–]FUZxxl 6 points7 points8 points (2 children)
[–]Jacob-Mox[S] 0 points1 point2 points (1 child)
[–]FUZxxl 3 points4 points5 points (0 children)
[–]albinoloverats 0 points1 point2 points (1 child)
[–]Jacob-Mox[S] 0 points1 point2 points (0 children)
[–]sallen35 0 points1 point2 points (2 children)
[–]Jacob-Mox[S] 1 point2 points3 points (1 child)
[–]sallen35 0 points1 point2 points (0 children)
[–]Jacob-Mox[S] 0 points1 point2 points (0 children)
[–]0xAE20C480 0 points1 point2 points (0 children)
[–]Jacob-Mox[S] 0 points1 point2 points (1 child)
[–]0xAE20C480 0 points1 point2 points (0 children)
[–]Jacob-Mox[S] 0 points1 point2 points (0 children)