answersLogoWhite

0

How make a calculator in c?

Updated: 8/11/2023
User Avatar

Wiki User

14y ago

Best Answer

#include

int main(){

int a, b, choice;

printf("This program implements a calculator\n");

do{

printf("Enter your choice:\n1-Addition\n2-Subtraction\n3-Multiplication\n4-Division\n5-Modulus\n6-Quit\t:");

scanf("%d", &choice);

switch(choice){

case 1: printf("Enter two numbers :");

scanf("%d%d", &a, &b);

printf("Sum = %d\n", a+b);

break;

case 2: printf("Enter two numbers :");

scanf("%d%d", &a, &b);

printf("Subtraction = %d\n", a-b);

break;

case 3: printf("Enter two numbers :");

scanf("%d%d", &a, &b);

printf("Product = %d\n", a*b);

break;

case 4: printf("Enter two numbers :");

scanf("%d%d", &a, &b);

printf("Quotient = %d\n", a/b);

break;

case 5: printf("Enter two numbers :");

scanf("%d%d", &a, &b);

printf("Remainder = %d\n", a%b);

break;

case 6: break;

default: printf("Invalid choice\n");

}

}while(choice != 6);

return 0;

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c;

printf("enter a,b,c");

scanf("%d%d%d",&a,&b,&c);

c=a+b;

printf("%d",sum is &c);

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

#include <iostream>

using namespace std;

int main()

{

int x, y;

char func;

cout << "Enter number: ";

cin >> x;

cout << "Enter function: (+, -, *, /)";

cin >> func;

cout << "Enter another number: ";

cin >> y;

switch(func)

{

case '+':

cout << x + y << endl;

break;

case '-':

cout << x - y << endl;

break;

case '*':

cout << x * y << endl;

break;

case '/':

cout << x / y << endl;

break;

default:

cout << "Invalid function" << endl;

break;

}

char wait;

cin >> wait;

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

#include<stdio.h>

#include<conio.h>

#include<process.h>

#include<dos.h>

#include<stdlib.h>

#include<iostream.h>

#include<graphics.h>

#include<math.h>

#include<string.h>

float *mem;

int X=0, Y=0;

int row=17,col=5;

char dummy;

char flag='d',flagp='0';

char bflag='u',bflagp='u';

int mflag=0;

char ch,ch1,ch2;

int sflag=0;

int midx,midy;

# define UNCLICKED 0

# define CLICKED 1

# define PI 3.14159

char str1[]={" Saikat Sengupta "};

void typeit (int x,int y,int spacing,char string[])

{

char temp[2];

for (int i=0;i<strlen(string);i++)

{

delay(100);

temp[0]=string[i];

temp[1]='\0';

outtextxy(x+(i+1)*spacing,y,temp);

}//endfor

}

void front()

{

int x,y,h;

for(x=0;x<=100;x++)

{

settextjustify(CENTER_TEXT,CENTER_TEXT);

setcolor(1);

settextstyle(1,0,4);

setusercharsize(x,6,x,3);

setcolor(14);

moveto(310,135);

outtext("..");

setcolor(6);

moveto(310,130);

outtext("I I");

if(x<50)

delay(30);

else

delay(20);

}

for(y=0;y<=100;y++)

{

setcolor(0);

settextstyle(1,0,4);

setusercharsize(y,6,y,3);

moveto(310,135);

outtext("..");

moveto(310,130);

outtext("I I");

if(y>20)

{

settextstyle(7,0,3);

setusercharsize(y-20,35,y-20,30);

setcolor(9);

outtext("CALCULATER");

setcolor(2);

outtext("___________");

delay(15);

if(y<100)

{

settextstyle(7,0,3);

setusercharsize(y-20,35,y-20,30);

setcolor(0);

outtext("CALCULATER");

}

}

}

//delay(1000);

settextstyle(3,0,2);

delay(50);

outtextxy(midx-200,midy," Project Assistant of NIELIT :-");

//x=10,y=10;

setcolor(6);

settextstyle(4,0,4);

typeit(midx-200,midy+50,15,str1);

getch();

//exit(1);

//closegraph();

}

char input();

double add(double,double,char);

double angle_conv(double);

void basecng(double,double);

/************************************************************/

/* */

/* THIS FUNCTION DRAWS THE BUTTONS OF THE CALCULATER */

/* */

/************************************************************/

void button_3d(int x1,int y1,int x2,int y2,int check,char* text,int color)

{

int up,low;

setfillstyle(1,7);

bar(x1,y1,x2,y2);

if(check==0) //Unclicked

up=15,low=8;

else

up=8,low=15; //Clicked

setcolor(low);

line(x2,y1,x2,y2);

line(x2-1,y1,x2-1,y2);

line(x1,y2,x2,y2);

line(x1+1,y2-1,x2,y2-1);

setcolor(up);

line(x1,y1,x2,y1);

line(x1+1,y1+1,x2-1,y1+1);

line(x1,y1,x1,y2);

line(x1+1,y1+1,x1+1,y2-1);

setcolor(color);

settextjustify(CENTER_TEXT,CENTER_TEXT);

outtextxy(x1+(x2 - x1)/2,(y1+(y2 - y1)/2)-2, text);

}

/*********************************************************************/

/* */

/* This function makes the opening screen */

/* */

/*********************************************************************/

void frontpage(void)

{

int mx, my;

mx = (getmaxx() / 2);

my = (getmaxy() / 2);

//SET baqckground color

setfillstyle(9, 1);

bar(0,0,getmaxx(),getmaxy());

//DRAW a bar, and make it look like a 3d bar

setfillstyle(1,7);

bar(50,20,600,400);

//DRAW lines for the top and left side

setcolor(03);

line(50,20,600,20);

line(51,21,599,21);

line(50,20,50,400);

line(51,21,51,399);

//DRAW lines for the bottom and right side

setcolor(11);

line(600,20,600,400);

line(599,21,599,400);

line(50,400,600,400);

line(51,399,600,399);

//DRAW two 3D bars for the left and right side

setfillstyle(9,8);

bar(70,40,100,380);

//getch();

bar(545,40,575,380);

setcolor(8);

rectangle(70,40,100,380);

rectangle(545,40,575,380);

setcolor(15);

line(100,40,100,380);

line(70,380,100,380);

line(575,40,575,380);

line(545,380,575,380);

//DRAW two 3D divider lines on both sides

setcolor(8);

line(110, 40, 110, 380);

line(535, 40, 535, 380);

setcolor(15);

line(111, 40, 111, 380);

line(536, 40, 536, 380);

//PRINT 3D text CALENDAR 2002

settextstyle(1, 0, 4);

settextjustify(1,1);

setcolor(15);

outtextxy(mx+2, my - 46, "MY CALCULATER");

setcolor(7);

outtextxy(mx + 1, my - 45, "MY CALCULATER");

setcolor(8);

outtextxy(mx + 2, my - 44, "MY CALCULATER");

//PRINT 3D text 2002

setcolor(15);

outtextxy(mx, my + 10, "2012");

setcolor(7);

outtextxy(mx + 1, my + 11, "2012");

setcolor(8);

outtextxy(mx + 2, my + 12, "2012");

//PRINT copyright notice

settextstyle(2, 0, 5);

setcolor(1);

outtextxy(mx + 1, my + 85, "Copyright 2012 by DOEACC");

getch(); //PAUSE for a while

}

/*********************************************************************/

/* */

/* This function makes the claculating screen */

/* */

/*********************************************************************/

void screen(int x1, int y1, int x2, int y2)

{

setlinestyle(0,0,1);

setfillstyle(SOLID_FILL, 8);

bar(x1, y1, x2, y2);

setfillstyle(SOLID_FILL, BLACK);

bar(x1+1, y1+1, x2-1, y2-1);

settextjustify(CENTER_TEXT, CENTER_TEXT);

setcolor(15);

line(x1+1, y1+1, x1+1, y2-1);

line(x1+1, y1+1, x2-1, y1+1);

line(x1+2, y1+2, x1+2, y2-2);

line(x1+2, y1+2, x2-2, y1+2);

setcolor(8);

line(x1+1, y2-1, x2-1, y2-1);

line(x2-1, y1+1, x2-1, y2-1);

line(x1+2, y2-2, x2-2, y2-2);

line(x2-2, y1+2, x2-2, y2-2);

}

/************************************************************************/

/* */

/* Mouse Related Functions */

/* */

/************************************************************************/

void init_mouse()

{

union REGS iregs, oregs;

iregs.x.ax = 0;

int86 (0x33, &iregs, &oregs);

if (oregs.x.ax 0);

ch=getch();

return ch;

}

/*************************************************************************/

/* */

/* This function performs the Calculations */

/* */

/*************************************************************************/

double add(double x,double y,char ch)

{

switch(ch)

{

case '+':

y=x+y;

break;

case '-':

y=x-y;

break;

case '*':

y=x*y;

break;

case '/':

y=x/y;

}

return y;

}

double angle_conv(double no)

{

if(flagp=='d')

{

if(flag=='r')

{

no=no*PI/180;

}

if(flag=='g')

{

no=no*1.1111111;

}

}

else if(flagp=='r')

{

if(flag=='d')

{

no=no*180/PI;

}

if(flag=='g')

{

no=no*180/PI*1.1111111;

}

}

else if(flagp=='g')

{

if(flag=='r')

{

no=no/(180*1.1111111)*PI;

}

if(flag=='d')

{

no=no/1.1111111;

}

}

return(no);

}

void basecng(double y,double pnt1)

{

char str[17];

switch(bflag)

{

case 'v':

itoa(y,str,8);

gotoxy(row,col);

printf("\t\t\t\t ");

gotoxy(row,col);

printf("%s",str);

bflagp='0';

break;

case 'w':

itoa(y,str,16);

gotoxy(row,col);

printf("\t\t\t\t ");

gotoxy(row,col);

printf("%s",str);

bflagp='0';

// getch();

break;

case 'x':

itoa(y,str,2);

gotoxy(row,col);

printf("\t\t\t\t ");

gotoxy(row,col);

printf("%s",str);

// getch();

bflagp='0';

break;

}

bflag='u';

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

double area(double width, double length)

{

return (width * length);

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Not possible.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How make a calculator in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the Example Output of Calculator Program in C plus plus?

example output of c++ calculator


How can you spell calculator in a calculator?

on a fxMs-82s Casio calculator C A 1 C U 1 A 7 0 (square root sign)


How do you make a scientific calculator in c plus plus?

#include &lt;stdio.h&gt; int main() { printf("the answer is 42"); }


What does the the letter C stand for on a calculator?

"C" = clear - pressing it sets all the calculations in the calculator back to zero.


What is the source code for scientific calculator in c?

What is the source code for scientific calculator in c?Read more: What_is_the_source_code_for_scientific_calculator_in_c


What does the c mean on a calculator?

clear


Can a potato power a calculator?

c


What things in a backpack start with C?

calculator


How do you put y equals c in a calculator?

if u have a regular calculator, you cannot put y =, if u have a graphing calculator, then you press the "y =" button


How do you make trigonometric calculator in c plus plus?

include file math.h and you get most C++ functions for trigonometry, for instance,sin(), cos(), tan(), asin(), acos(), and atan() etc.


How do you write mixed fractions on a calculator?

It depends on the calculator; usually there's an "a b/c" button, which is activated when you press shift or a "2nd function" button on the calculator. However if this does not help, most calculators now have online instruction manuals. Just type the model and make into google.


How many combinations of four can you make out of 6?

type in your calculator C(6,4) like the combination of 6 things taken 4 at a time