Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/articles/c-tutorials/)
-   -   Calculator program in C (http://www.go4expert.com/articles/calculator-program-c-t689/)

kadjam 30Mar2010 01:29

Re: Calculator program in C
 
what about a supermarket service to calculate prices of goods with fixed prices. with a cashier log in

kadjam 30Mar2010 01:38

Re: Calculator program in C
 
what about a supermarket service to calculate prices of goods with fixed prices. with a cashier log in

saji777 22Jun2010 12:34

Re: Calculator program in C
 
tnx but i think we needed a top source from calculator
Specal thanks

newtosee 28Jun2010 03:55

Re: Calculator program in C
 
Hy, I begun studying c++ a few days ago and I came across this topic and decided to write a similar program in c++...

The code was a bit inspired from the original c calculator :)

Anyway, I would love to read your feedback ^^

Code:

#include <cstdlib>
#include <cstdio>
#include <iostream>


using namespace std;

double x;
double y;
double multi(double x, double y);
double divi(double x, double y);
double sub (double x, double y);
double add(double x, double y);


int main(int argc, char *argv[])
{
    char a, z;
    for(;;)
{
    cin>> x; cin>> z; cin>>y;
if (z=='*'){cout<<"=" <<multi (x,y)<< endl;}
if (z=='/'){cout<<"=" <<divi (x,y)<< endl;}
if (z=='-'){cout<<"=" <<sub (x,y)<< endl;}
if (z=='+'){cout<<"=" <<add (x,y)<< endl;}

cout<<"Would you like to do another operation? [y/n]";
cin>>a;
if
(a!='y')
{break;}
}
    system("PAUSE");
    return EXIT_SUCCESS;
}
double multi (double x, double y)
{return x*y;}
double divi (double x, double y)
{return x/y;}
double sub (double x, double y)
{return x-y;}
double add (double x, double y)
{return x+y;}

Cheers!

cute_dhanju 5Aug2010 11:27

Re: Calculator program in C
 
gud,....................

atena.sharifi 12Aug2010 02:41

Re: Calculator program in C
 
:worried: hi ,thanks for program ,but this program in the line 25 give error . error : cannot call 'main' from within the program in function main().
please help me .
sorry for level low language.

shabbir 12Aug2010 08:32

Re: Calculator program in C
 
Quote:

Originally Posted by atena.sharifi (Post 71438)
:worried: hi ,thanks for program ,but this program in the line 25 give error . error : cannot call 'main' from within the program in function main().
please help me .
sorry for level low language.

You are using a Cpp compiler and try a C compiler and it would work. For some old TC compiler just renaming the file to .c would compile it for you

matuatua 7Sep2010 13:17

Re: Calculator program in C
 
i will try it later,anyway thank u for that code

hemamca 13Sep2010 17:03

Re: Calculator program in C
 
hai do i know which editor is best now in c / c++ languages. is better Microsoft or Turbo C

shabbir 13Sep2010 17:04

Re: Calculator program in C
 
TC is outdated and not used anymore.


All times are GMT +5.5. The time now is 02:19.