c++
Whats output this program in c++: for(i=0;1;i++) printf("god") and what?
You will get a error because you need a loop condition it cant be just 1. for example to print god 5 times make loop condition like for(i=0; i %26lt;=5;i++) then it will print "god" five times.
Reply:Yes. I agree. It will keep printing godgodgodgod...
cos the expression has been set to a "1". If you want it to print only once you will have to change that as i%26lt;1.
Good Luck!!!
Reply:it gives me an error.. did u check ur code?
Reply:It outputs:
godgodgodgodgod ...
why?
Because the second argument evaluated, always gets true!
It simply gets cycled.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment