I want the program to output the "year" after user types that year; however, all that seems to happen is the default statement occurs. I used similar code from a basic calculator which worked fine with char
and float
but, with this, I cannot work out where I am wrong.
// Simple program to produce a description of an event that happened within the chosen year.
#include <iostream>
using namespace std;
int main()
{
int nYear;
cout << "Enter a year between 1980 and 1982: ";
cin >> nYear;
switch(nYear)
{
case '1980':
cout << "1980"; // I will replace "year" with fact once code works.
break;
case '1981':
cout << "1981";
break;
case '1982':
cout << "1982";
break;
default:
cout << "Error try again with specified year";
break;
}
return 0;
}