The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
While doing some mathematical problems, calculator plays a major role. We the programmer, are not supposed to use physical calcuator, we just create it by our own coding. Here is a C program to perform arithmetic operations for solving your mathematical problems
It's time to write a c program to perform arithmetic operations.
#include <stdio.h> int main() { int num1, num2, choice, answer; printf("Enter any two integers : "); scanf("%d %d ", &num1, &num2); printf("\nPress 1 for Addition "); printf("\nPress 2 for Subtraction "); printf("\nPress 3 for Multiplication "); printf("\nPress 4 for Division "); printf("\nPress other key to exit "); printf("\n\n"); printf("\nEnter ur choice : "); scanf("%d" ,&choice); switch(choice) { case 1: answer = num1 + num2; printf("\n%d + %d = %d ", num1, num2, answer); break; case 2: answer = num1 - num2; printf("\n%d - %d = %d ", num1, num2, answer); break; case 3: answer = num1 * num2; printf("\n%d * %d = %d ", num1, num2, answer); break; case 4: answer = num1 / num2; printf("\n%d / %d = %d ", num1, num2, answer); break; default: printf("\nInvalid Choice "); } return 0; }
Enter any two integers : 20 10 Press 1 for Addition Press 2 for Subtraction Press 3 for Multiplication Press 4 for Division Press other key to exit Enter your choice : 1 20 + 10 = 30
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019