#include<iostream>
#include<cmath>
using namespace std;
int main()
{
float hi,wi,bmi;
char an;
do{
cout<<" Enter your weight in 'kg' (kilograms): ";
cin>>wi;
cout<<endl;
cout<<" Enter your height in 'm' (meters): ";
cin>>hi;
cout<<endl;
//calculation
bmi=wi/pow(hi,2);
cout<<" Your bmi is "<<bmi;
cout<<endl;
if(bmi<18.5)
{
cout<<" You are underweight.";
cout<<endl;
}
else if(bmi==18.5)
{
cout<<" You are near underweight.";
cout<<endl;
}
else if(18.5<bmi && bmi<24.9)
{
cout<<" You are considered normal weight.";
cout<<endl;
}
else if(24.9<bmi && bmi<29.9)
{
cout<<" You are overweight."<<endl;
cout<<" You may wish to consult with your physician for medical help";
cout<<endl;
}
else if(bmi==29.9)
{
cout<<" You are near obese."<<endl;
cout<<" You may wish to consult with your physician for medical help";
cout<<endl;
}
else if(30<bmi)
{
cout<<" You are obese."<<endl;
cout<<" You may wish to consult with your physician for medical help";
cout<<endl;
}
cout<<endl;
cout<<" Do you wanna check onces more ?(Y/N)?";
cin>>an;
}while(an=='y'||an=='Y');
return 0;
}
Wednesday, May 7, 2014
C++ Coding for SriLanka NIC birth year finding
#include<iostream>
using namespace std;
int main()
{
int nu,s,g;
cout<<"Enter the NIC number";
cin>>nu;
// Year
s=nu/10000000%100;
cout<<"You was born in 19"<<s<<endl;
// gender
g=nu/10000%1000;
if (g<500)
{
cout<<"You are male";
}
else if(g>500)
{
cout<<"You are female";
}
return 0;
}
using namespace std;
int main()
{
int nu,s,g;
cout<<"Enter the NIC number";
cin>>nu;
// Year
s=nu/10000000%100;
cout<<"You was born in 19"<<s<<endl;
// gender
g=nu/10000%1000;
if (g<500)
{
cout<<"You are male";
}
else if(g>500)
{
cout<<"You are female";
}
return 0;
}
Friday, May 2, 2014
C++ Blood Donar and recipent program.
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char type[10],an;
cout<<"World Blood Donor Day is celebrated every 14th of June"<<endl;
cout<<"It encourages people to give blood and save lives."<<endl;
cout<<endl;
do{
cout<<"Please Enter your Blood Group here :";
cin>>type;
cout<<endl;
if(strcmp("AB+",type)==0||strcmp("ab+",type)==0 )
{
cout<<"You can donate blood to a person with type AB+."<<endl;
cout<<"You can recieve blood from anyone."<<endl;
cout<<"AB is the universal recipient. "<<endl;
}
else if(strcmp("AB-",type)==0||strcmp("ab-",type)==0)
{
cout<<"You can donate blood to a person with type AB+ or AB-."<<endl;
cout<<"You can recieve blood from O-,A-,B- and AB-."<<endl;
cout<<"AB is the universal recipient. "<<endl;
}
else if(strcmp("B+",type)==0||strcmp("b+",type)==0)
{
cout<<"You can donate blood to a person with type AB+ or B+."<<endl;
cout<<"You can recieve blood from O+,O-,B+ and B-."<<endl;
}
else if(strcmp("B-",type)==0||strcmp("b-",type)==0)
{
cout<<"You can donate blood to a person with type B+,B-,AB+ and AB-."<<endl;
cout<<"You can recieve blood from O- and B-."<<endl;
}
else if(strcmp("A+",type)==0||strcmp("a+",type)==0)
{
cout<<"You can donate blood to a person with type A+ or AB+."<<endl;
cout<<"You can recieve blood from O+,O-,A+ and A-."<<endl;
}
else if(strcmp("A-",type)==0||strcmp("a-",type)==0)
{
cout<<"You can donate blood to a person with type A+,A-, AB+ and AB-."<<endl;
cout<<"You can recieve blood from O- and A-."<<endl;
}
else if(strcmp("o-",type)==0||strcmp("O-",type)==0)
{
cout<<"You can donate blood to a anyone."<<endl;
cout<<"You can recieve blood from O-."<<endl;
cout<<" O is the universal donor."<<endl;
}
else if(strcmp("o+",type)==0||strcmp("O+",type)==0)
{
cout<<"You can donate blood to a person with type O+,A+, B+ and AB+."<<endl;
cout<<"You can recieve blood from O+ and O-."<<endl;
cout<<" O is the universal donor."<<endl;
}
else
{
cout<<"Invaild type of group, try again";
}
cout<<endl;
cout<<"Do you wanna check another blood group? (Y,N)";
cin>>an;
}while(an=='y'||an=='Y');
return 0;
}
#include<cstring>
using namespace std;
int main()
{
char type[10],an;
cout<<"World Blood Donor Day is celebrated every 14th of June"<<endl;
cout<<"It encourages people to give blood and save lives."<<endl;
cout<<endl;
do{
cout<<"Please Enter your Blood Group here :";
cin>>type;
cout<<endl;
if(strcmp("AB+",type)==0||strcmp("ab+",type)==0 )
{
cout<<"You can donate blood to a person with type AB+."<<endl;
cout<<"You can recieve blood from anyone."<<endl;
cout<<"AB is the universal recipient. "<<endl;
}
else if(strcmp("AB-",type)==0||strcmp("ab-",type)==0)
{
cout<<"You can donate blood to a person with type AB+ or AB-."<<endl;
cout<<"You can recieve blood from O-,A-,B- and AB-."<<endl;
cout<<"AB is the universal recipient. "<<endl;
}
else if(strcmp("B+",type)==0||strcmp("b+",type)==0)
{
cout<<"You can donate blood to a person with type AB+ or B+."<<endl;
cout<<"You can recieve blood from O+,O-,B+ and B-."<<endl;
}
else if(strcmp("B-",type)==0||strcmp("b-",type)==0)
{
cout<<"You can donate blood to a person with type B+,B-,AB+ and AB-."<<endl;
cout<<"You can recieve blood from O- and B-."<<endl;
}
else if(strcmp("A+",type)==0||strcmp("a+",type)==0)
{
cout<<"You can donate blood to a person with type A+ or AB+."<<endl;
cout<<"You can recieve blood from O+,O-,A+ and A-."<<endl;
}
else if(strcmp("A-",type)==0||strcmp("a-",type)==0)
{
cout<<"You can donate blood to a person with type A+,A-, AB+ and AB-."<<endl;
cout<<"You can recieve blood from O- and A-."<<endl;
}
else if(strcmp("o-",type)==0||strcmp("O-",type)==0)
{
cout<<"You can donate blood to a anyone."<<endl;
cout<<"You can recieve blood from O-."<<endl;
cout<<" O is the universal donor."<<endl;
}
else if(strcmp("o+",type)==0||strcmp("O+",type)==0)
{
cout<<"You can donate blood to a person with type O+,A+, B+ and AB+."<<endl;
cout<<"You can recieve blood from O+ and O-."<<endl;
cout<<" O is the universal donor."<<endl;
}
else
{
cout<<"Invaild type of group, try again";
}
cout<<endl;
cout<<"Do you wanna check another blood group? (Y,N)";
cin>>an;
}while(an=='y'||an=='Y');
return 0;
}
Subscribe to:
Posts
(
Atom
)