Caluculator

chound 0 Tallied Votes 211 Views Share

calculator using macros in C++

#include<iostream.h>

#define MULTI(a, b) a*b
#define DIV(a, b) a/b
#define ADD(a, b) a+b
#define SUB(a, b) a-b

void main()
{
	float a, b, c[4];
	int i; 
	char d='y';
	while(d=='y'||d=='Y')
	{
		cout<<"Enter the 2 nos.";
		cin>>a>>b;
		c[0]=MULTI(a, b);
		c[1]= DIV(a, b);
		c[2]= ADD(a, b);
		c[3]= SUB(a, b);
		cout<<"Answers(Order *, /, +, -):\n";
		for(i=0;i<4;i++)
		{
			cout<<"\n"<<i<<")"<<c[i]<<endl;
		}
		cout<<"\nAnother one(yes/no): ";
		cin>>d;
	}
}
YoungCoder 1 Junior Poster

Calculator ;)

bumsfeld 413 Nearly a Posting Virtuoso

Caluculator is cute!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.