Posts

Showing posts from June, 2012

Write a program performing as calculator which allows all Arithmetic Operators with operands as input

1. Write a C program for performing as calculator which allows all Arithmetic Operators with operands from terminal. Few Input and Output sample are given below: Recommended : Study Char/Char Array in C/C++                                  Sample Input: 1 + 4             Sample Output: 5             Sample Input: 8 % 2             Sample Output: 0             Sample Input: 6 / 2             Sample Output: 3             Sample Input: 5 / 2             Sample Output: 2.5 Source code in c: #include<stdio.h> #include<conio.h> main() { int a,b,z,x,w,h; char c; float y,m=0.0; printf("\nWelcome To My Calculator\n"); AB: printf("\nenter to calculate (Ex:2+2)\n"); scanf("%d%c%d",&a,&c,&b); z=(a+b); x=(a*b); w=(a-b); h=(a%b); y=(a/b); m=y; switch(c) { case '+' : printf("%d+%d=%d",a,b,z); break; case '-' : printf("%d-%d=%d",a,b,w); break; ca