cout/cin

I am trying to use cout and cin to output a message for the user to enter the number 1 or 2 but cout and cin come up as errors. I have the statement
#include <iostream> in the program but it's still coming up as an error. Im wondering if there is another type of method I could use. This is a little example of the coding

//Have user input number
cout << "Enter number 1 or 2" << endl;
cin >> n;


//Test to run the while loop
if (n = 1)
{
//Output the # on die face, in numercial order
// and turn specific LED(s) on for two seconds
printf("#1 ");
OutputData(32);
Sleep(2000);


printf("#2 ");
OutputData(9);
Sleep(2000);


printf("#3 ");
OutputData(41);
Sleep(2000);


printf("#4 ");
OutputData(89);
Sleep(2000);


printf("#5 ");
OutputData(121);
Sleep(2000);

printf("#6 ");
OutputData(95);
Sleep(2000);

//Turn off LEDs
printf("LEDs off ");
OutputData(0);
}

//if 2 then output numbers in reverse order
else if (n = 2)
{
printf("#6 ");
OutputData(95);
Sleep(2000);

printf("#5 ");
OutputData(121);
Sleep(2000);

printf("#4 ");
OutputData(89);
Sleep(2000);

printf("#3 ");
OutputData(41);
Sleep(2000);

printf("#2 ");
OutputData(9);
Sleep(2000);

printf("#1 ");
OutputData(32);
Sleep(2000);

//Turn off the LEDs
OutputData(0);
}
if (n = 1)
this is assignment, try testing for equality:
 
if(n == 1) 
throughout your program
Do you have using namespace std before your main function? If you dont you will have to use std:: infront of cout or cin.
Thanks to you both, it works now. I can't believe I forgot using namespace std, minor mistakes haha
Topic archived. No new replies allowed.