What could be wrong here?

phldbr

Limp Gawd
Joined
Nov 11, 2004
Messages
204
A simple for loop that is supposed to print out: 9876543
Code:
#include <iostream.h>
int main (void)
{
    int x;
    
    For (x=9; x>2; x--)
    cout << x ; 
        
     
    return 0;
}

I keep getting two errors when compiling.
 
cout is part of the std namespace. You need to have this above your main statement:
using namespace std;

You could also prepend cout with std:
std::cout << x;
 
for shouldn't be capitalized, presumably. then again you might want to tell us what the errors are that you're getting
 
I keep getting two errors when compiling.
You should show us the errors. We're left to guess, otherwise.

My guesses are that you mean "for" instead of "For", and that you mean "std::cout" instead of "cout".
 
:D
wow... I did not know that if I wrote it with a capital letter it would not work.
Thanks a lot guys.
Wrote "for" instead of "For" and everything is good.
 
C and C++ are case-sensitive for both variable names and language keywords.
 
Back
Top