Question #39421

write a program to get 2 integers from the user & display the results of all arithmetic operations.
write a program to get two floating point numbers from the user & display the results of all arithmetic operations.
1

Expert's answer

2014-02-24T13:52:02-0500
#include <stdio.h>
int main() {
    float numberA, numberB;
    scanf("%g %g", &numberA, &numberB);
    printf("\t%g + %g = %g\n", numberA, numberB, numberA + numberB);
    printf("\t%g - %g = %g\n", numberA, numberB, numberA - numberB);
    if (numberB == 0) {
        printf("\tDivision by zero\n");
    } else {
        printf("\t%g / %g = %g\n", numberA, numberB, numberA / numberB);
    }
    printf("\t%g * %g = %g\n", numberA, numberB, numberA * numberB);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS