Quick Posts

Post Page Advertisement [Top]

This is a basic syntax and code for developing a calculator in C language. For this purpose you must have a C/C++ compiler. You can download one from any developing organization. But different compilers have different syntax. Here i am writing code that is basically working for Turbo C++ compiler (This can work in both C and C++ programming).
This is a freeware and also very easy and user-friendly too.
You can download it from Here
1: SourceForge    or    2: CodePlex.       
(This tool is compatible to all OS with 32-bit or 64-bit)
After Installing a short-cut might appear at desktop named "Turbo C++" or a little changed. Launch it.

Here is the Script or code Writing a calculator that can do basic maths operations like adding, subtracting, dividing, multiplying and modulus operation
"

#include<conio.h>
#include<stdio.h>
void main()
{
int x,y; 
char op;
clrscr();
printf("Enter 1st number, operator and 2nd number:");
scanf("%d %c %d", &x,&op,&y);
switch(op)
{
case '+':
printf("%d+%d=%d",x,y,x+y);
break;
case '-':
printf("%d-%d=%d",x,y,x-y);
break;
case '/':
printf("%d/%d=%d",x,y,x/y);
break;
case '*':
printf("%d*%d=%d",x,y,x*y);
break;
case '%':
printf("%d%%%d=%d",x,y,x%y);
break;
default:
printf("Invalid operation");
}
getch();
}

"
For understanding working of program click here. If you find any trouble say in comment and click on contact us page. 

No comments:

Bottom Ad [Post Page]

| Designed by Colorlib