Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For my code, I want the result of any number divided by 0 to be ERROR: Cannot Divide By 0. But whenever I run it
For my code, I want the result of any number divided by 0 to be "ERROR: Cannot Divide By 0". But whenever I run it I get "Floating point exception (core dumped)". Is there any way I can change this?
int main (void) int num1; int num2; int sum int difference int product; int quotient; char operator; printf("Enter integer +I scanf("%d %c %d", &num1, I*/ integer: "); &operator, &num2); quotientnuml / num2; sumnuml num2; difference- numl - num2; productnuml *num2; if (operator+') printf("%d + %d %d", num1, num2, sum); else if (operator') printf("%d %d- %d", num1, num2, difference) ; ) %d-%d", else if (operator' printf("%d num1, num2 , product); * else if (operator:- '/') { if (num20) printf("%d / %d Error: Cannot divide by ", num1, num2); y else t printf("%d / %d-%d", num1, num2 , quotient); return ; Enter integer +-* |/ integer 7/0 Floating point exception (core dumped)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started