saving . . . saved QUESTION PROBLEM has been deleted. QUESTION PROBLEM has been hidden .
QUESTION PROBLEM
##### Question
Write a  program to check whether the age of the employee is between 20 and 60?

Is the above question correct?

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

Or this one

C-and-Cpp Nested-If-And-Switch-Statement 08-09 min 0-10 sec 24-03-20, 11:33 a.m. vigneshwarigopalan

Hello Vigneshwar,
Your question is not clear.  Are you finding it difficult to write a program that calculates upto age 60?
24-03-20, 1:52 p.m. nancy
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;
}

24-03-20, 4:45 p.m. vigneshwarigopalan

#include <stdio.h>
void main()
{
int x, y;
printf ("enter the age between 20 to 60") ;
scanf ("%d, &y) ;
x=y/10;
switch(x)
{
case 2:
printf ("age of employ between 20 to 29");
break;
case 3:
printf ("age of employ between 30to39") ;
break;
case 4:
printf ("age of employ between 40to49") ;
break;
case 5:
printf ("age of employ between 50to59");
break;
default:
printf ("invalid number") ;
break;
}
getch() ;
}

11-07-20, 10:55 a.m. 1921271242003
y = 45
x=4
age of employ is between 40 to 49
11-07-20, 10:58 a.m. 1921271242003

By nested if

#include<stdio.h>
int main()
{
int a;
printf("enter the age of employee between 20to59:");
scand("%d",&a);
if(a/10==2)
{
printf("age of employee in between 20 to 29\n");
}
else if (a/10==3)
{
printf(" age of employee in between 30to39\n");
}
else if(a/10==4)
{
printf("age of employee in between 40to49\n");
}
else if (a/10==5)
{
printf("age of employee in between 50to59\n");
}
else
{
printf("age of employee not in range\n");
}
return 0;
}

11-07-20, 1:54 p.m. Sakshichoudhary
The output is as follows
34
age of employee between 30to39
11-07-20, 1:55 p.m. Sakshichoudhary

//Assignment 7
// program using by switch case  statement

#include<stdio.h>
void main()
{
int x, y;
printf(" enter the age between 20 to 59\n");
scanf("%d", &y);
x=y/10;
switch(x)
{
case 2:
printf(" age of employee between 20 to 29\n");
break;
case 3:
printf(" age of employee between 30 to 39 \n");
break;
case 4:
printf(" age of employee between 40 to 49 \n");
break;
case 5:
printf(" age of employee between 50 to 59 \n");
break;
default:
printf("Invalid age\n");
break;
getch();

Output as follows
y=55
x=5
age of employee between 50 to 59
11-07-20, 8:45 p.m. Kirtana_maru

By using switch case , assignment 7
#include <stdio.h>
void main ()
{
int  a,b;
printf ("enter the age between 20 to 59\n");
scanf ("%d",&b);
a=b/10;
switch (a)

{
case 2:
printf ("age of the employee between 20 to 29\n");
break ;
case 3:
printf ("age of the employee between 30 to 39\n");
break ;
case 4:
printf ("age of the employee between 40 to 49\n");
break;
case 5:
printf ("age of the employee between 50 to 59\n");
break ;
default:
printf ("invalid age \n");
break;
}
getch ();
}

Output as follows
b= 35
a=3
Age of the employee between 30 to 39

11-07-20, 9:15 p.m. s19_more_sneha@mgmcen.ac.in

Assignment -7
By using switch case Statement

#include<stdio.h>
void main ()
{
int a,b;
printf("enter the age between 20 to59\n");
scanf("%d",&b);
a=b/10;
switch (a)
{
case 2:
printf("age of employee between 20 to 29\n");
break;
case 3:
printf("age of employee between 30 to 39\n");
break;
case 4:
printf("age of employee between 40 to 49\n");
break;
case 5:
printf("age of employee between 50 to 59\n");
break;
default:
printf("invalid age\n");
break;
}
getch();
}

Output is as follows
b=25
a=2
age of employee between 20 to 29

12-07-20, 1:47 p.m. 1921271242105

//Assignment 7
// program using by switch case  statement

#include<stdio.h>
void main()
{
int x, y;
printf(" enter the age between 20 to 59\n");
scanf("%d", &y);
x=y/10;
switch(x)
{
case 2:
printf(" age of employee between 20 to 29\n");
break;
case 3:
printf(" age of employee between 30 to 39 \n");
break;
case 4:
printf(" age of employee between 40 to 49 \n");
break;
case 5:
printf(" age of employee between 50 to 59 \n");
break;
default:
printf("Invalid age\n");
break;
getch();

Output as follows
y=55
x=5
age of employee between 50 to 59
15-07-20, 9:59 p.m. 1921271242121