#include <stdio.h> //Sum float sum(float x, float y); float difference(float x, float y); float product(float x, float y); float quotient(float x, float y); int main() { float n1, n2; float S, D, P, Q; char symbol; printf("Enter two numbers:\n"); scanf("%f", &n1); scanf(" %f", &n2); printf("[+]Sum [-]Difference [*]Product [/]Quotient [x]Exit\n"); printf("Enter Choice:"); scanf("%s", &symbol); switch(symbol) { case'+':S=sum(n1, n2);printf("Sum:%.2f", S); break; case'-':D=difference(n1, n2);printf("Difference:%.2f", D); break; case'*':P=product(n1, n2);printf("Product:%.2f", P); break; case'/':Q=quotient(n1, n2);printf("Quotient:%.2f", Q); break; case'x':printf("Exit!"); break; } } float sum(float x, float y) { return (x+y); } float difference(float x, float y) { return (x-y); } float product(float x, float y) { return (x*y); } float quotient(float x, float y) { return (x/y); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter