Write a program that reads a real number X and displays its category:

  • Category A if (0 < = X < 37)
  • Category B otherwise

Difficulty level
Video recording
This exercise is mostly suitable for students
#include <stdio.h>

int main()
{
    double X;
    printf("Enter a real number: ");
    scanf("%lf",&X);
    if(X>=0 && X <37)
        printf("%.2lf is of category A\n",X);
    else
        printf("%.2lf is of category B\n",X);

    return 0;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Asymptotic Analysis 18