SPECIFICATION:
(2). C Program for taking Two integer operands and one operator form user, performs the
operation and then prints the result.
(Consider the operators +,-,*, /, % and use Switch Statement)
DESCRIPTION:
Consider two operands a and b, and assign the values for them at the time of execution. By making
use of the operator entered, the above given values are computed .
ALGORITHM:
Step 1: START
Step 2: Read the values of a,b
Step 3: Read Choice Ch
Step 4: Case _ begin
4.1 : + : Display a+b after computing a+b
4.2 : - : Display a-b after computing a-b
4.3 : * : Display a*b after computing a*b
4.4: / : Display a*b after computing a/b
4.5: % : Display a*b after computing a%b
4.6: Default : Display Invalid Choice
Case _end
Step 5 :STOP
FLOWCHART:
START
Ch==?
Default
Compute :
a*b
Compute
: a+b
Compute :
a/b
Compute
: a%b
Compute :
a-b
Show
a+b
Show
a-b
Show
a/b
Show
a*b
STOP
Show
a%b
Invalid
Choice
PROGRAM
/* C Program which takes two integer operands and one operator
from the user,performs the operation and then print the result */
Program name:
// wk2c.c
/* Done By : C-Faculty
Dated: 15/10/2013*/
#include<stdio.h>
int main()
char op;
int a,b,c;
clrscr();
scanf("%d%d",&a,&b);
scanf(" %c",&op);
}
return(0);
ORIGINAL OUTPUT :
Output (1)
enter two operands:3 5
enter an operator:*
product of two numbers 3 5 is: 15
Output (2)
enter two operands:5 2
enter an operator:/
quotient of two numbers 5 2 is: 2
Output (3)
enter two operands:5 2
enter an operator:%
reminder of two numbers 5 2 is: 1
VIVA VOCE QUESTIONS:
1) What are the various types of arithemetic operators ?
Ans: addition (+), multiplication(*), subtraction (-), division(/) ,
modulo(%).
---xXx--