*Ask the user to input a number.
*If the number is
< 10 print “Number is less than 10”
< 20 print “Number is less than 20 but greater than 10”
< 30 print “Number is less than 30 but greater than 20”
< 40 print “Number is less than 40 but greater than 30”
< 50 print “Number is less than 50 but greater than 40”
< 50 print “Number is greater than 50”
*Use a loop to repeat this process until the user inputs -1.
Output:
Input a number (-1 to exit): 5
Number is less than 10_
Input a number (-1 to exit): 19
Number is less than 20 but greater than 10.
Input a number (-1 to exit): 25
Number is less than 30 but greater than 20.
Input a number (-1 to exit): 55
Number is greater than 50.
Input a number (-1 to exit): -1
Press any key to continue…
#include <stdio.h>
int main(void)
{
int a=0;
printf("please enter a number : \n");
scanf("%i",&a);
switch(a)
{
if (a<=10);
printf("Number is less than 10");
break;
if (a<=20 && a>10);
printf("Number is less than 20 but greater than 10");
break;
if (a<=30 && a>20);
printf("Number is less than 30 but greater than 20");
break;
if (a<=40 && a>30);
printf("Number is less than 40 but greater than 30");
break;
if (a<=49 && a>40);
printf("Number is less than 50 but greater than 40");
break;
if (a>=50);
printf("Number is greater than 50");
break;
return 0;
}
}