0

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 
BhandariS
  • 606
  • 8
  • 20

1 Answers1

4

cout,cinand 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
}
izlin
  • 2,129
  • 24
  • 30