Program to check whether software engineer is allowed in pub or not is a simple program to check using conditional statements.

What is a condition to enter in a pub?
The common condition to enter into the pub is the age should be greater than 18 and the person must have a girlfriend or boyfriend.

How to check whether a software engineer is allowed in a pub nor not?
First, we take input name, age and partner status (yes/ no).
Next, we check conditions
User age is greater than 18 and having a partner with him/her, then the user is allowed in a pub.
if age is greater than 18 but not having a partner, then the user is not allowed in a pub.
if age is less than 18 but having a partner, then the user is not allowed in a pub.

Example:
Name = John
Do you have partner = yes
age = 20
Output: John is allowed in a pub.

Program to check whether software engineer is allowed in pub or not

#include <stdio.h>

int main()
{
char name[30];
char YesNo[10];
int age;

//input name
printf("Enter the name : ");
gets(name);

printf("Do you have partner (Y-Yes, N-No) : ");
gets(YesNo);
printf("Enter your age : ");
scanf("%d",&age);

if((!strcmp(YesNo,"yes")) && age >= 18 )
printf("%s ! You are allowed in pub ......",name);
else if((!strcmp(YesNo,"no")) && age >= 18)
printf("%s ! You are not allowed in pub ......",name);
else if((!strcmp(YesNo,"yes")) && age <= 18 )
printf("%s ! You are not 18..you are not allowed in pub",name);

return 0;
}

Output :

Program to check whether software engineer is allowed in pub or not

Write A Comment