Thursday, February 11, 2021

USEING SWITCH OPERATION IN "C" TO CREATE SIMPLE CALCULATOR

   USEING SWITCH OPERATION IN "C" TO          CREATE SIMPLE CALCULATOR

#include<stdio.h>

main(){

char a;

float m, n, p;

printf("Enter the operator we want to operated = ");

scanf("%c", &a);

printf("Enter the m and n numbers ");

scanf("%f  %f", &m, &n);

switch(a){

case '+':

p = m + n;

printf("The sum of %f and %f numbers = %f", m, n, p);

break;

case '-':

     p = m-n;

printf("The different of %f and %f numbers = %f", m, n, p);

break;

case '*':

p = m*n;

printf("The product of %f and %f numbers = %f", m, n, p);

break;

case '/':

if(n !=0){

p = m/n;

         printf("The division of %f and %f numbers = %f", m, n, p);

}

else

printf("The division of %f and %f numbers not define ", m, n);

break;

defalt :

printf(" Not valid operation")

}

}

mathextention

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 comments:

Post a Comment