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


Hii, I think we can write a code with the help of the information in the video and the pervious video.
I hope the code below might help you or if some one else is having the same doubt. We just have to add the decimal value .2 before %d for the code to read after 6 so that it will read only for the quotient 6.00 and rest which are above that will not be excepted. 

#include <stdio.h>
int main()
{
int a;
printf("enter the age between 20 to 60\n");
scanf(".2%d",&a);

//for age less than 20
if(a/10==1)
{
printf("the age is less than the permitted age\n");
}

//for age 20 to 29
else if(a/10==2)
{
printf("the age group is between 20 to 29\n");
}

//for age 30 to 39
else if(a/10==3)
{
printf("the age group is between 30 to 39\n");
}

//for age 40 to 49
else if(a/10==4)
{
printf("the age group is between 40 to 49\n");
}

//for age 50 to 59
else if(a/10==5)
{
printf("the age group is between 50 to 59\n");
}

//for age 60
else if(a/10==6.00)
{
printf("the age group is  60\n");
}

//for age 61 and above
else 
{
printf("the age is not in range\n");
}
return 0;
}
14-08-21, 10:16 p.m. MayurDhotre


Log-in to answer to this question.