Reputation: 29
This is what I have so far. I have been testing it on c++ shell and it gives me error.
#include <iostream>
#include <string>
int main() {
cout << "Enter a number between 3 and 12: ";
int n;
cin >> n;
if(n>=3 && n<=12)
cout<<"Good number."endl;
else
cout<<"Bad number"endl;
return 0; //indicates success
}//end of main
Upvotes: 0
Views: 92
Reputation: 2138
cout
,cin
and endl
are part of the standard library so you need to use std::cout
, std::cin
and std::endl
. You can use using namespace std;
on the beginning as well (after the includes, but it is considered as bad programming style).
Change your output to:
std::cout << "Good number." << std::endl;
Here is a working example:
int main() {
std::cout << "Enter a number between 3 and 12: ";
int n;
std::cin >> n;
if(n>=3 && n<=12)
std::cout<<"Good number."<<std::endl;
else
std::cout<<"Bad number"<<std::endl;
return 0; //indicates success
}
Upvotes: 4