0
kadjam's Avatar, Join Date: Mar 2010
Newbie Member
what about a supermarket service to calculate prices of goods with fixed prices. with a cashier log in
0
kadjam's Avatar, Join Date: Mar 2010
Newbie Member
what about a supermarket service to calculate prices of goods with fixed prices. with a cashier log in
0
saji777's Avatar
Newbie Member
tnx but i think we needed a top source from calculator
Specal thanks
0
newtosee's Avatar, Join Date: Jun 2010
Newbie Member
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!
0
cute_dhanju's Avatar, Join Date: Aug 2010
Newbie Member
gud,....................
0
atena.sharifi's Avatar, Join Date: Aug 2010
Newbie Member
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.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by atena.sharifi View Post
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
0
matuatua's Avatar, Join Date: Sep 2010
Light Poster
i will try it later,anyway thank u for that code
0
hemamca's Avatar, Join Date: Sep 2010
Newbie Member
hai do i know which editor is best now in c / c++ languages. is better Microsoft or Turbo C
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
TC is outdated and not used anymore.