CPP All : Simple Real World Problems
Concept Learning Code Sheets

#### Celsius to Fahrenheit Conversion #1843

Temperature conversion from degree Celsius to degree Fahrenheit using standard formula

#include <iostream>
using namespace std;
int main( )
{
float tc,tf;
cout<<"Give temperature in deg. C = ";
cin>>tc;
tf=tc*9/5+32;
cout<<"Temperature in Fahrenheit = "
<<tf<<" deg. F"<<endl;
return 0 ;
}

#### Temperature conversion c2f and f2c #1845

Converting given temperature assuming if it is in Celsius as Fahrenheit and if is in Fahrenheit as Celsius

#include <iostream>
using namespace std;
int main( )
{
float t,tc,tf;
cout<<"Give temperature = ";
cin>>t;
tf=t*9/5+32;
tc=(t-32)*5/9;
cout<<t<<" deg. C = "<<tf<<" deg. F"<<endl;
cout<<t<<" deg. F = "<<tc<<" deg. C"<<endl;
return 0 ;
}

#### Salary Calculation #1847

A real world application of financial calculation with an example of salary calculations

#include <iostream>
using namespace std;
int main()
{
float salary,salary_to_give,basic,
da=30,hra=12,pf=10,tax=15;
cout<<"Give Basic : ";cin>>basic;
salary=basic + da/100*basic + hra/100*basic;
salary_to_give=salary-pf/100*basic-tax/100*salary;
cout<<"Net Salary = "<<salary<<endl;
cout<<"Salary to give = "<<salary_to_give<<endl;
return 0 ;
}

#### Finding bricks required to build a wall #1849

Bricks required to build a wall with an assumption of walls made with bricks only.

#include <iostream>
using namespace std;
int main( )
{
float bl=25,bb=12,bh=9;
float wl,wh;
int bc;
cout<<"Assume wall of one brick breadth -"<<endl;
cout<<"Give wall length and height (m):";
cin>>wl>>wh;
bc=(wl*12*wh*10000)/(bl*bb*bh);
cout<<"Brick Size (in cm) = "
<<bl<<"X"<<bb<<"X"<<bh<<endl;
cout<<"No. of bricks required ="<<bc<<endl;
return 0 ;
}

#### Finding the paint quantity for door painting #1851

Based on the spread of the paint, exact paint quantity can be computed for a given door size.

#include <iostream>
using namespace std;
int main()
{
cout<<"Assume that two sides of a door has to be painted -"<<endl;
cout<<"Give door width and height (m): ";
cin>>width>>height;
cout<<"Give paint spread in litre/m2 : ";