#include<stdio.h>
/*Function diclaration for calculator*/
float add(float num1,float num2);
float sub(float num1,float num2);
float mult(float num1,float num2);
float div(float num1,float num2);
int main()
{
char operator;
float num1,num2,result=0;
/*print welcome message */
printf("WELCOME TO SIMPLE CALCULATOR\n");
printf("----------------------------\n");
printf("Enter the [number 1] [+,-,*,/] [number 2]\n");
/*Input two number and operactor from user */
scanf("%f %c %f" ,&num1 ,&operator ,&num2);
switch(operator)
{
case '+':
result =add(num1,num2);
break;
case '-':
result =sub(num1 ,num2);
break;
case '*':
result =mult(num1,num2);
break;
case '/':
result =div(num1,num2);
break;
{
if(num2==0)
{
printf("oops divide by zero");
}
else
{
printf("div %f" ,result);
}
}
default:
printf("Invalid operactor");
}
/*print the result*/
printf("%f %c %f = %f" ,num1 ,operator ,num2 , result);
return 0;
}
/*Function to Add two number*/
float add(float num1, float num2)
{
return num1+num2;
}
/*Function to Subtract two number*/
float sub(float num1, float num2)
{
return num1-num2;
}
/*Function to multiply two number*/
float mult(float num1, float num2)
{
return num1*num2;
}
/*Function to divide two number*/
float div(float num1, float num2)
{
return num1/num2;
}
Can anyone understand why if conditions is not execute
Answers
Answered by
0
Answer:
ggfrxghbfuhhutgefcdgbjhbgujvfgrguibgfyjhyihdyiqweerttyyuuiooppp FFS s
Similar questions
Hindi,
6 months ago
Environmental Sciences,
6 months ago
Social Sciences,
6 months ago
Chemistry,
1 year ago
English,
1 year ago
Biology,
1 year ago
English,
1 year ago