Using Operator C++ part 2

I have posted about how to using operator in C++, i have remarked it into spesific more with data type float and also integer exactly.

/*
Name: Using operator
Copyright: http://tutorialcoding.blogspot.com
Author: Rifki Yandhi
Date: 18/10/09 21:15
Description:
*/

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
int intA,intB,intProc;
float floatA,floatB;

cout<<"\nImplementation operators +,-,*,/,%"<<endl;
do
{
cout<<"\n1. Data type is Integer"<<endl;
cout<<"2. Data type is Float"<<endl;
cout<<"3. Exit..."<<endl;
cout<<"\nWhat kind of process do you want ? [1,2,3]: ";
cin >> intProc;
}while(intProc > 3 || intProc < 0 );

if ( intProc == 1)
{
cout<<"\n\nYou choose integer data type";
cout<<"\nA = ";
cin >> intA;
cout<<"B = ";
cin >> intB;

cout<<"\n(+) A + B = "<<(intA+intB)<<endl;
cout<<"(-) A - B = "<<(intA-intB)<<endl;
cout<<"(*) A * B = "<<(intA*intB)<<endl;
cout<<"(/) A / B = "<<(intA/intB)<<endl;
cout<<"(%) A % B = "<<(intA%intB)<<endl;

}
else if ( intProc == 2 )
{
cout<<"\n\nYou choose float data type";
cout<<"\nA = ";
cin >> floatA;
cout<<"B = ";
cin >> floatB;

cout<<"\n(+) A + B = "<<(floatA+floatB)<<endl;
cout<<"(-) A - B = "<<(floatA-floatB)<<endl;
cout<<"(*) A * B = "<<(floatA*floatB)<<endl;
cout<<"(/) A / B = "<<(floatA/floatB)<<endl;
}
else
exit(0);

getch();
}



Free source code and program download


0 comments:

Post a Comment