Click here to Skip to main content
15,917,456 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Write a C++ program to demonstrate the working of a calculator.
Posted
Updated 5-Apr-10 22:01pm
v2

Try it :) :
bool IsACalculatorHere()
{
  STARTUPINFO si = {0};
  PROCESS_INFORMATION pi = {0};
  si.cb = sizeof(si);
  return (FALSE != ::CreateProcess(NULL,
                                   _T("calc.exe"),
                                   NULL,
                                   NULL,
                                   FALSE,
                                   0,
                                   NULL,
                                   NULL,
                                   &si,
                                   &pi));
}
 
Share this answer
 
Ummm, No.

Take your homework question somewhere else.
 
Share this answer
 
Yes boss!
OK, done that.
Should I send it directly to your tutor?
Where should I send the invoice?
 
Share this answer
 
#include<iostream.h>
    float add(float,float);
    float subtract(float,float);
    float multiply(float,float);
    float divide(float,float);
    void main()
{
	float num_1,num_2;
	
	char select,choice;
	cout << "                      *-:CALCULATOR PROGRAM:-* " << endl;
     
	cout << "                      -**********************-"<< endl ;
	
	cout << endl;
	cout << "                          -:RESTRICTIONS:- \n "<< endl;

	cout << "#1) PLEASE ENTER INTEGER TAYPE VALE LIKE (.......-2,-1,0,1,2,.....):" << endl; 
    
	cout << endl;
	cout << "#2) PLEASE ENTER VALID OPERATOR LIKE (*,-,/,+):" << endl;
	
	cout << "--------------------------------------------------------------" << endl;
input: cout << endl;
	cout << "       ENTER FIRST DIGIT  : " ;
	cin >> num_1;
	cout << endl;
	
	cout << "SELECT ONE OPERATION IN WHICH OF THESE (+,*,-,/) THAT YOU WANT TO OPERATE:\n\n";

	cout << "YOUR SELECTED OPERATION IS: ";
	
	cin >> select;
	cout << endl;
    cout << "       ENTER SECOND DIGIT : ";
	cin >> num_2;
	cout << endl;

	if ( num_1 > 3.4e-38 && num_1 < 3.4e38 && num_2 > 3.4e-38 && num_2 < 3.4e3 && select == '+' || select == '*' || select == '-' || select == '/' )
	{

	if ( select == '+' )
		
		cout << "            YOUR ANSWER IS: " << add(num_1,num_2);
	if( select== '-' )
		
		cout << "            YOUR ANSWER IS: " << subtract(num_1,num_2);
	if ( select == '*' )
		
		cout << "            YOUR ANSWER IS: " <<multiply(num_1,num_2) ;
	if ( select == '/' )
		
		cout << "            YOUR ANSWER IS: " << divide(num_1,num_2);
	cout << endl;
	cout << "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-"<<endl;
	
	cout << endl;
    cout << "ENTER 'y' TO CONTINUE AND 'n' TO STOP :\n" << endl;
	cout << "                 DO YOU WANT YO CONTNUE [y/n]:  ";
	cin >> choice;
	if ( ( choice == 'y' ) || ( choice == 'y' ) )
	goto input;
	}
	else
		cout << endl ;
		cout << "               INVALID INPUT!" << endl;
		cout << endl;
	
	
	
	
	
}
float add ( float x, float y)
{
	return ( x + y );
}
float subtract ( float x, float y)
{
	return ( x - y );
}
float multiply ( float x, float y)
{
	return ( x * y );
}
float divide ( float x, float y)
{
	return ( x / y );
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900