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


#include<stdio.h>
int main()
{
    int x;
    printf("type your age");
    scanf("%d",&x);
    if(x>60)
    {
    printf("the age of employee is not between 20-60");
    }
    else if(x<20)
    {
     printf("the age of employee is not between 20-60"); 
     }
     else
      {
       printf("the age of employee is between 20-60");
       }
       return 0;
 }
07-08-24, 8:42 p.m. Nikki5D4


#include<stdio.h>
Void main()
{
int age;
Printf("enter your age :");
Scanf("%d",&age);
if(age<20)
Printf("the age of employee is not between 20-60");
elseif(age>60)
Printf("the age of employee is not between 20-60");
else
Printf("the age of employee is between 20-60");
}


Output:
enter your age : 12
the age of employee is not between 20-60

11-08-24, 7:47 p.m. 238T1A05D9


#include<stdio.h>
Void main()
{
int age;
Printf("enter your age :");
Scanf("%d",&age);
if(age<20)
Printf("the age of employee is not between 20-60");
elseif(age>60)
Printf("the age of employee is not between 20-60");
else
Printf("the age of employee is between 20-60");
}


Output:
enter your age : 12
the age of employee is not between 20-60
12-08-24, 2:44 p.m. tanmayi.P


#include<stdio.h>
void main()
{
int age;
printf("enter your age");
scanf("%d",&age);
if(age<20)
printf("the age of employee is not between 20-60");
elseif(age>60)
printf("the age of employee is not between 20-60");
else
printf("the age of employee is between 20-60");
}


Output:
enter your age : 12
the age of employee is not between 20-60

12-08-24, 3:04 p.m. 238T1A05E1


#include<stdio.h>
void main()
{
int age;
printf("enter your age");
scanf("%d",&age);
if(age<20)
printf("the age of employee is not between 20-60");
elseif(age>60)
printf("the age of employee is not between 20-60");
else
printf("the age of employee is between 20-60");
}


Output:
enter your age : 12
the age of employee is not between 20-60

12-08-24, 3:04 p.m. 238T1A05E1


#include<stdio.h>
void main()
{
int age;
printf("enter your age");
scanf("%d",&age);
if(age<20)
printf("the age of employee is not between 20-60");
elseif(age>60)
printf("the age of employee is not between 20-60");
else
printf("the age of employee is between 20-60");
}


Output:
enter your age : 12
the age of employee is not between 20-60

12-08-24, 3:22 p.m. 238T1A05E2


#include<stdio.h>
#include<conio.h>
void main()
{
int age;
printf("enter the age of a employee:");
scanf("%d",&age);
if(age<20)
printf("%d less than 20",age);
else if(age>60)
printf("%d greater than 60",age);
else
printf("%d is between 20 and 60",age);
getch();
}
output
enter the age of a employee:37
37 is between 20 and 60
12-08-24, 3:44 p.m. 238T1A05G7


#include<stdio.h>
#include<conio.h>
void main()
{
int age;
printf("enter the age of a employee:");
scanf("%d",&age);
if(age<20)
printf("%d less than 20",age);
else if(age>60)
printf("%d greater than 60",age);
else
printf("%d is between 20 and 60",age);
getch();
}
output
enter the age of a employee:40
40 is between 20 and 60
16-08-24, 4:51 p.m. 238T1A05F5


#include<stdio.h>
#include<conio.h>
void main()
{
int age;
printf("enter the age of a employee:");
scanf("%d",&age);
if(age<20)
printf("%d less than 20",age);
else if(age>60)
printf("%d greater than 60",age);
else
printf("%d is between 20 and 60",age);
getch();
}
19-08-24, 3:02 p.m. nasreensk2005@gmail.com


Log-in to answer to this question.