Sunday, September 18, 2011

WAP which takes operands and operator as input and performs the operation


/*
  Name: WAP which takes operands and operator as input and performs the operation
  Author: Parveen Malik 
  Date: 18/09/11 02:42
*/


#include<stdio.h>
#include<conio.h>
int main(void)
{
    int a,b;
    char ch;
    printf("Enter any two integer values\n");
    scanf("%d%d",&a,&b);
    printf("Enter the required operator (+,-,*,/) : ");
     fflush(stdin);
    scanf("%c",&ch);
    switch(ch)
{
    case '+' : printf("\na + b : %d",a+b);
    break;
    case '-' : printf("\na - b : %d",a-b);
    break;
    case '*' : printf("\na x b : %d",a*b);
    break;
    case '/' : printf("\na / b : %d",a/b);
    break;
    default : 
            printf("\nInvalid operator, Please check once again \n");
            }
            getch();
            return 0;
            }
 
OUTPUT : 

0 comments:

Post a Comment