Simple Calculator in C-Language

#include<stdio.h> #include<conio.h> #include<stdlib.h> main(){ float a, b, c; int op; printf("\n Enter the first value : "); scanf("%f" , &a); printf("\n Enter the second value : "); scanf("%f" , &b); printf("\n\n Press 1 for Addition. \n Press 2 for Subtraction. \n Press 3 for Multiply. \n Press 4 for Divid."); scanf("%d" , &op); switch(op){ case 1 : c = a + b; printf("\n\n\t %.2f + %.2f : %.2f" , a, b, c ); break; case 2 : c = a - b; printf("\n\n\t %.2f - %.2f : %.2f" , a, b, c ); break; case 3 : c = a * b; printf("\n\n\t %.2f * %.2f : %.2f" , a, b, c ); break; case 4 : c = a / b; printf("\n\n\t %.2f / %.2f : %.2f" , a, b, c ); break; } getch(); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.