Program to check whether the number is 1, 2 or 3 using if-else statement - C++ Programming
Check whether the number is 1, 2 or 3 using if-else statement:
Program:
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "Enter the value of n" << endl;
cin >> n;
if (n==1)
{
cout << "Number is One" << endl;
}
else if (n==2)
{
cout << "Number is Two" << endl;
}
else if (n==3)
{
cout << "Number is Three" << endl;
}
else
{
cout << "None of these" << endl;
}
return 0;
}
Program:
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "Enter the value of n" << endl;
cin >> n;
if (n==1)
{
cout << "Number is One" << endl;
}
else if (n==2)
{
cout << "Number is Two" << endl;
}
else if (n==3)
{
cout << "Number is Three" << endl;
}
else
{
cout << "None of these" << endl;
}
return 0;
}
Comments
Post a Comment