if-else and if-else-if C++ programs

if-else & if-else-if Programs:



Program:

#include < iostream >
using namespace std;
int main()
{
int a;
cin >> a;
if(a == 5)
{
cout << "Yes, the number is 5" << endl;
}
else
{
cout << "No; the number is not 5" << endl;
}
return 0;
}

Program 2:

#include < iostream >
using namespace std;
int main()
{
int a;
cin >> a;
if (a == 1)
{
cout << "1" << endl;
}
else if (a == 2)
{
cout << "2" << endl;
}
else
{
cout << "none" << endl;
}
return 0;
}

Comments

Popular posts from this blog

How to display the output in C++