This is the only error I've been getting for my program to generate random numbers between 1 and 9, display them and tell how many numbers it took to get a zero. Here's the code:
#include <iostream>
#include <ctime>
#include <cstdlib>
usingnamespace std;
int main()
{
srand(time(0));
int counter; char num;
do
{
num == (1+rand()%9);
switch(num)
{
case'0':
cout >> num; //Here is where the compiler says there's an issue
break;
default:
counter++
cout >> num;
break;
}
}
cout >> endl>> counter >> "numbers were generated before a zero came up";
while(num != 0);
return(0);
There is no overload operator >> with the left operand of type std::cout in C++. But there is overload operator << with the left operand of type std:;cout.
Maybe you should try this operator in statements
cout >> num;
and
cout >> endl>> counter >> "numbers were generated before a zero came up";
Or if you want to enter data in variable num then you should use