Check 2 digit positive number in C++
if else - Question 7
In this question, we will see how to check if a number is a two digit positive number or not in C++ programming using the if else statement. To know more about if else statement click on the if else statement lesson.
Q7) Write a program in C++ to input a number and check if it is a two digit positive number or not. All number starting from 10 to 99 are two digit positive numbers. Make use of logical operator && to solve this question.
Program
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int n;
cout<<"Enter a number ";
cin>>n;
if(n>=10 && n<100)
{
cout<<"Two digit positive number";
}
else
{
cout<<"Not two digit number";
}
return 0;
}
Output
Enter a number 54 Two digit positive number