Friday, July 31, 2009

Using a loop that displays all the integers between 13 and 93 that end in 3? in C++ in loops?

i need to know how can i do this? and it got to be in c++ and loops thanks

Using a loop that displays all the integers between 13 and 93 that end in 3? in C++ in loops?
First is the most obvious way...





#include %26lt;iostream.h%26gt;


int main(){for(int x=13;x%26lt;94;x+=10)cout%26lt;%26lt;x%26lt;%26lt;"\n";return 0;}





Yes it really works. Compiled and tested. :)





For those that must have white space...





#include %26lt;iostream.h%26gt;


int main(){


int x;


for(x=13; x%26lt;94; x+=10){


cout %26lt;%26lt; x %26lt;%26lt; "\n";


}


return 0;


}








And lastly for some fun...





#include %26lt;iostream.h%26gt;


int main(){for(int x=1;x%26lt;10;x++)cout%26lt;%26lt;x%26lt;%26lt;"3\n";return 0;}





Only the 10's digit changes so you really only need to loop to 9.





Shadow Wolf
Reply:a number that ends in 3 is a number x where


x % [what]? = 3
Reply:for (int i = 13; i%26lt;93; i+=10)


{


print i;


}



tanning

No comments:

Post a Comment