Dremendo Tag Line

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 <stdio.h>
#include <conio.h>

int main()
{
    int n;
    printf("Enter a number ");
    scanf("%d",&n);
    if(n>=10 && n<100)
    {
        printf("Two digit positive number");
    }
    else
    {
        printf("Not two digit number");
    }
    return 0;
}

Output

Enter a number 54
Two digit positive number
video-poster