Turing's Craft exercise stumped me... seems too easy.

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-12-31T06:37:50Z Indexed on 2010/12/31 6:54 UTC
Read the original article Hit count: 216

Filed under:

"Write a for loop that prints the integers 1 through 40, separated by spaces or new lines. You may use only one variable, count which has already been declared as an integer."

So I use...

for(count = 1; count <= 40; count++)
{
    cout << " " << count;
}

but they are using stdio.h as the only header and cout is not recognized. It hints that the output format should be (" ",count), but I can't figure out what print function to use. stdio.h can use fprintf or fwrite, but I don't have enough parameters for either function. Any ideas?

© Stack Overflow or respective owner

Related posts about c++