Write a program that takes operands and one operator and perform the operation and print the result using switch statement or case. | CODE WITH SHARAD

Write a program that takes operands and one operator and perform the operation and print the result using switch statement or case.

Written by Sharad Raj on 13th of March, 2018

BASIC PROGRAMS   C LANGUAGE PROGRAMS

PROGRAM CODE

#include<stdio.h>

#include<conio.h>

void main()

{
char oper;

int c,a,b;

clrscr();

printf(Enter two numbers :);

getch(%d%d,&a,&b);

printf(Enter the operation to be performed : );

scanf(%c,&oper);

switch (oper)

{

case +:

{

c=a+b;

printf(ADDITION = %d,c);

break;

}

 

 

case -:

{

c=a-b;

printf(SUBSTRACTION = %d,c);

break;

}

case *:

{

c=a*b;

printf(MULTIPLICATION = %d,c);

break;

}

case /:

{

c=a/b;

printf(DIVISION = %d,C);

break;

}

default:

{

printf(Wrong choice.);

}

getch();

}


Comments


Contact