Computer Science, asked by Alfiya2006allu, 2 months ago

answer me please urgent​

Attachments:

Answers

Answered by Aryansingh001
2

Answer:

Explanation:

#include <stdio.h>

int main(){

char wish;

float num1,num2,result;

int flag =1;

printf(" Enter - , + , * ,/ for knowing result \n");

scanf("%c" , &wish);

printf ("Enter number 1\n");

scanf("%f", &num1 );

printf ("Enter number 2\n");

scanf("%f" , &num2 );

switch (wish)

{

case '+':

result =num1+num2;

break ;

case'-':

result =num1-num2;

break ;

case '/':

{

if (num2 ==0)

{

flag = 0;

}

else

{

result =num1/num2;

}

break ;

}

case'*':

result = num1 *num2;

break ;

default : printf ("error");

break ;

}

if (flag ==1)

{

printf ("%f %c %f =%f" , num1, wish,num2 ,result );

}

else

{

printf ("%f %c %f = undefined" ,num1 ,wish ,num2 );

}

}

Similar questions