what is the program of do while that ...
you can type any number but when u type zero it will stop the program?
thanks for the help
peace!

Recommended Answers

All 7 Replies

You sound incredibly lazy. Seeing as this is a trivial program, try it yourself first.

yes, narue maybe you right am lazy...am still new on this....

main()

{int  x=1

   do{ printf("%d",x);
         x++;
           if(x==0),
             {
                printf("end") 
              }
        }while(x>0)

,,,,,,
is this right?

You sound incredibly lazy. Seeing as this is a trivial program, try it yourself first.

yes, narue maybe you right am lazy...am still new on this....

is my program right? the one i post?

Replace ++x; with scanf("%d", &x); and your logic is reasonably sound. Otherwise it's broken because the loop will never end[1].


[1] It will end, but not in a well-defined way.

[1]....
main()

{int x=1

do{ printf("%d",x);
scanf("%d", &x);
if(x==0),
{
printf("end")
}
}while(x>0)

...

[2]
main()

{
scanf("%d", &x);

int x=1;

do{ printf("%d",x);
x++;
if(x==0),
{
printf("end")
}
}while(x>0)

,,,,,

the program will be shown like you said in the number one....
but if i do it like in the number 2...is it also right?

but if i do it like in the number 2...is it also right?

No. Might I recommend dropping down a level and learning basic programming through pseudocode? Your C is just awful, and not understanding the the fundamentals won't help.

No. Might I recommend dropping down a level and learning basic programming through pseudocode? Your C is just awful, and not understanding the the fundamentals won't help.

hehehe..yes narue your right am really awful in c coz i skip c programming for atleast a year and i forgot everything and now am doing it again haha...
so thats it thanks a lot man,, for your time....
,,,,i'll just use the program that u gave...
peace!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.