saving . . . saved QUESTION PROBLEM has been deleted. QUESTION PROBLEM has been hidden .
QUESTION PROBLEM
Title
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

Answers:

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

Login to add comment


#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

Login to add comment


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

Login to add comment


//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


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:01 p.m. MayurDhotre


<font size="4">Program in c by switch case:</font>


#include <stdio.h>
int main()
{
    int x, y;
    printf("Enter the age of employee between 20 to 60:");
    scanf("%d",&y);
    x=y/10;
    switch  (x)
    {
        case 2:
        printf("The age of the employee is in the range of 20 to 29\n");
        break;
        case 3:
        printf("The age of the employee is in the range of 30 to 39\n");
        break;
        case 4:
        printf("The age of the employee is in the range of 40 to 49\n");
        break;
        case 5:
        printf("The age of the employee is in the range of 50 to 59\n");
        break;
        default:
        printf("invalid age range \n");
    }
    return 0;
}

output:
Enter the age of employee between 20 to 60: 37
The age of the employee is in  the range of 30 to 39


<font size="4">Program in c by using nested if:</font>

#include <stdio.h>
int main()
{
    int x, y;
    printf("Enter the age of employee between 20 to 60:");
    scanf("%d",&y);
    
    if(y/10==2)
    {
        printf("The age of the employee is in the range of 20 to 29\n");
    }
    else if(y/10==3)
    {
        printf("The age of the employee is in the range of 30 to 39\n");
    }
    else if(y/10==4)
    {
        printf("The age of the employee is in the range of 40 to 49\n");
    }
    else if(y/10==5)
    {
        printf("The age of the employee is in the range of 50 to 59\n");
    }
    else 
    {
        printf("invalid age range\n");
    }
    return 0;
}

output:
Enter the  age of employee between 20 to 60 : 57
The age of the employee is in the range of 50 to 59


<font size="4">program in cpp using nested if:</font>

#include <iostream>
using namespace std;

int main() 
{
    int x, y;
    cout<<"Enter the age of employee between 20 to 60: ";
    cin>>y;
    
    if(y/10==2)
    {
      cout<<"The age of the employee is in the range of 20 to 29\n";
    }
    
    else if(y/10==3)
    {
      cout<<"The age of the employee is the range of 30 to 39\n";
    }
    else if(y/10==4)
    {
      cout<<"The age of the employee is in the range of 40 to 49\n";
    }
    else if(y/10==5)
    {
      cout<<"The age of the employee is in the range of 50 to 59\n";
    }
    else
    {
        cout<<"invalid age range\n";
    }
    return 0;
}

output:
Enter the age of employee between 20 to 60: 48
The age of the employee is in the range of 40 to 49


<font size="4">Program in cpp using switch case:</font>

#include <iostream>
using namespace std;

int main() 
{
    int x, y;
    cout<<"Enter the age of employee between 20 to 60: ";
    cin>>y;
    x=y/10;
    
    switch  (x)
    {
        case 2:
        cout<<"The age of the employee is in the range of 20 to 29\n";
        break;
        case 3:
        cout<<"The age of the employee is in the range of 30 to 39\n";
        break;
        case 4:
        cout<<"The age of the employee is in the range of 40 to 49\n";
        break;
        case 5:
        cout<<"The age of the employee is in the range of 50 to 59\n";
        break;
        default:
        cout<<"invalid age range \n";
    }
    return 0;
}

output:
Enter the age of employee between 20 to 60: 38
The age of the employee is in the range of 30 to 39
















21-01-24, 4:06 p.m. Vaishnavi2885


#include<stdio.h>
#include<conio.h>
void main()
{
int a;
printf("enter the age of employee");
scanf("%d",&a);
if(a<20)
printf("the employee age is not in between 20 to 60);
elseif(a==20)
printf("the employee age is 20")
else
printf("the employee age is in between 20 to 60")
}
12-08-24, 2:35 p.m. 238T1A05D8


#include<stdio.h>
#include<conio.h>
void main()
{
int a;
printf("enter the age of employee");
scanf("%d",&a);
if(a<20)
printf("the employee age is not in between 20 to 60);
elseif(a==20)
printf("the employee age is 20")
else
printf("the employee age is in between 20 to 60")
}
12-08-24, 2:49 p.m. 238T1A05D3


#include<stdio.h>
#include<conio.h>
void main()
{
int a;
printf("enter the age of employee");
scanf("%d",&a);
if(a<20)
printf("the employee age is not in between 20 to 60);
elseif(a==20)
printf("the employee age is 20")
else
printf("the employee age is in between 20 to 60")
}
12-08-24, 3:09 p.m. Shalini_09


#include<stdio.h>
#include<conio.h>
void main()
{
int a;
printf("enter the age of employee");
scanf("%d",&a);
if(a<20)
printf("the employee age is not in between 20 to 60);
elseif(a==20)
printf("the employee age is 20")
else
printf("the employee age is in between 20 to 60")
}
12-08-24, 3:31 p.m. 238T1A05E2


#include<stdio.h>
#include<conio.h>
void main()
{
int a;
printf("enter the age of employee");
scanf("%d",&a);
if(a<20)
printf("the employee age is not in between 20 to 60);
elseif(a==20)
printf("the employee age is 20")
else
printf("the employee age is in between 20 to 60")
}
12-08-24, 3:47 p.m. rehmatshaik795@gmail.com


#include<stdio.h>
#include<conio.h>
void main()
{
int a;
printf("enter the age of employee");
scanf("%d",&a);
if(a<20)
printf("the employee age is not in between 20 to 60);
elseif(a==20)
printf("the employee age is 20")
else
printf("the employee age is in between 20 to 60")
}
16-08-24, 4:49 p.m. 238T1A05F5


// program to check whether the age of the employee is between 20 and 60
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
printf("enter the age of employee");
scanf("%d",&a);
if(a<20)
printf("the employee age is not in between 20 to 60);
elseif(a==20)
printf("the employee age is 20");
else
printf("the employee age is in between 20 to 60");
getch();
}
19-08-24, 2:30 p.m. 238T1A05G1


// program to check whether the age of the employee is between 22 and 58
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
printf("enter the age of employee");
scanf("%d",&a);
if(a<22)
printf("the employee age is not in between 20 to 60);
elseif(a==22)
printf("the employee age is 22");
else
printf("the employee age is in between 22 to 58");
getch();
}
19-08-24, 2:58 p.m. nasreensk2005@gmail.com


Log-in to answer to this question.