POP Using C - VTU Lab Program-1
POP Using C - VTU Lab Program-1
Algorithm:
Step 1: START
Step 2 : Read two numbers
say num1 and num2
Step 3: Read arithmetic operator(+,-,*,/)
say it as op
Step 4: Check if op is matching with '+'
Compute result=num1+num2
display result
Check if op is matching with '-'
Compute result=num1-num2
display result
Check if op is matching with '*'
Compute result=num1*num2
display result
Check if op is matching with '/'
Check if num2 is 0
Display the given operation cannot be performed
else
Compute result=num1/num2
display result
else
display Error Message
Step 5: STOP
Flowchart:
Program:
#include<stdio.h>
#include<stdlib.h>
void main()
{
float num1, num2, result;
char op;
scanf(“%c”, &op);
{
result = num1 + num2;
printf(“Result is %0.2f \n”, result);
{
result = num1 - num2;
printf(“Result is %0.2f \n”, result);
}
{
result = num1* num2;
printf(“Result is %0.2f \n”, result);
}
else if(op = = ‘/ ’ )
{
if(num2 = = 0)
{
}
else
{
}}
else
{
printf (“Entered operator is invalid \n”);
}}
OUTPUT:
Case 1: Enter the operator (+,-,*,/)
+
Please enter two numbers: 4 2
Result is 6.00