0% found this document useful (0 votes)
61 views7 pages

PF Lab 4

The document contains 5 programming tasks that involve conditional statements in C++. The tasks include: 1) Converting uppercase letters to lowercase, 2) Creating a basic calculator, 3) Checking eligibility for an insurance scheme based on age, 4) Printing city names based on area codes, 5) Calculating wages based on hours worked with different pay rates. For each task, the code and expected output are provided.

Uploaded by

Gaylethunder007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views7 pages

PF Lab 4

The document contains 5 programming tasks that involve conditional statements in C++. The tasks include: 1) Converting uppercase letters to lowercase, 2) Creating a basic calculator, 3) Checking eligibility for an insurance scheme based on age, 4) Printing city names based on area codes, 5) Calculating wages based on hours worked with different pay rates. For each task, the code and expected output are provided.

Uploaded by

Gaylethunder007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

EXPERIMENT 04

CONDITIONAL STATEMENTS II
Tasks
1. Write a Program that converts an upper case letter into a lower case letter.(Hint :
upper case letter + 32 gives lower case)

CODE
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
char x,y;
cout<<"enter upper case letter=";
cin>>x;
y=x+32;
cout<<"lower case letter="<<y;
getch();
}
OUTPUT
2. Write a program for a simple calculator .The program should take two float values and the
operation to be performed (char) from the user. The calculator should perform addition, subtraction,
multiplication and division.
Example execution
Enter first number: 4
Enter Second number: 10
Enter operation to be performed (Select from +,-,*, /): +
Result: 14.

CODE
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
float x,y,s,t,v,n;
char z;
cout<<"enter first number=";
cin>>x;
cout<<"enter second number=";
cin>>y;
cout<<"Enter operation to be performed (Select from +,-,*, /):";
cin>>z;
if(z=='+')
{
s=x+y;
cout<<"sum="<<s;
}
else if(z=='-')
{
t=x-y;
cout<<"subtraction="<<t;
}
else if(z=='*')
{
v=x*y;
cout<<"multiplication="<<v;
}
else if(z=='/')
{
n=x/y;
cout<<"division="<<n;
}
getch();
}
OUTPUT
3. Write a program for an insurance company that allows only people from a certain age group to be
eligible for a specific insurance scheme. If the age is greater than 45 or less than 25 it says you are
not eligible. Else it prints you are eligible.
CODE
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int x;
cout<<"enter age=";
cin>>x;
if(x>45||x<25)
{
cout<<"you are not eligible";
}
else
{
cout<<"you are eligible";
}
getch();
}
OUTPUT
4. The following table shows telephone area codes in the state of Georgia along with the largest city
in each area

Area code Major city


229 Albany
404 Atlanta
470 Atlanta
478 Macon
678 Atlanta
706 Columbus
762 Columbus
770 Atlanta
912 Savannah
Write a C++ program that inputs the city area code and prints the corresponding city name.
CODE
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int code;
cout<<"enter code=";
cin>>code;
if(code==229)
{
cout<<"city is albany";
}
else if(code==404||code==470||code==678||code==770)
{
cout<<"city is atlanta";
}

else if(code==478)
{
cout<<"city is Macon";
}

else if(code==706||code==762)
{
cout<<"city is coiumbus";
}

else if(code==912)
{
cout<<"city is Savannah";
}
getch();
}
OUTPUT
5. Write a program that determines the wages of a person based on working hours. If a person works
for less than 5 hours his wage per hour is Rs.400.if he works for more than 5 and less than 8 hours
wage per hour increases to Rs.560.an addition of Rs.2000 are given as overtime for workers who
work up till 12 hours
CODE
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int x,y;
cout<<"enter hours=";
cin>>x;
if(x<5)
{
y=x*400;
cout<<"wages="<<y;
}
else if(x>5&x<8)
{
y=x*560;
cout<<"wages ="<<y;
}
else if(x>=12)
{
y=x*560+2000;
cout<<"wages="<<y;
}
getch();
}
OUTPUT

You might also like