saving . . . saved DOUBT IN QUESTION has been deleted. DOUBT IN QUESTION has been hidden .
DOUBT IN QUESTION
Title
Question
   A)Write a  program to check whether the age of the employee is between 20 and 60?

  B) Write a  program to check whether the age of the employee is between 20 and 59?

   Here, I mentioned two questions.Which one is correct?We cant able to write program to the Question A?In the tutorial  also asked the students to write coding for A?





  B) Write a  program to check whether the age of the employee is between 20 and 59?

CODING:-


#include<stdio.h>
int main()
{
   int a;
   printf("Enter the age of a employee between 20 to 59");
   scanf("%d",&a);
   
  
   if((a/10)==5)
{
   printf(" AGE RANGE BETWEEN 50 to 59");
}
   else if((a/10)==3)
{
 printf(" AGE RANGE BETWEEN 30 to 49");
}
else if((a/10)==2)
{
  printf(" AGE RANGE BETWEEN 20 to 29");
}



else

{
printf("AGE NOT IN RANGE\n");
}
return 0;
}


C-and-Cpp Nested-If-And-Switch-Statement 08-09 min 10-20 sec 24-03-20, 4:44 p.m. vigneshwarigopalan

Answers:

You are missing the case where a/10 is 4
After comparing a/10 to 5, the next else if should check if a/10 is 4

26-03-20, 7:09 p.m. bhaskar76


You can do it this way
#include <stdio.h>
int main ()
{
int x;
printf("Type your Age\n");
scanf("%d",&x);
if (x > 60)
{
printf("The age of employee is not between 20-60\n");
}
else if (x < 20)
{
printf("The age of employee is not between 20-60\n");
}
else 
{
printf("The age of employee is between 20-60\n");
}
return 0;
}
08-08-20, 6:32 p.m. Sahil006


Log-in to answer to this question.