A Simple C Program for Mathematical Calculation

How to do Mathematics with C Language

This is a program to do simple arithmetic operations Addition, Subtraction and Multiplication of a given number, in this program we are not taking numbers as input from the user, instead we will pre-define it within the program using a ‘int’ variable to make this C program simpler for beginners.

So, lets take a look at the source code of this C program this arithmetic operations.


#include <stdio.h> // Include the contents of the standard header
void main() //Defining main function 
   int first, second, add, subtract, multiply; // Defining local variables

   clrscr(); //Calling clear screen function
   first=22; //Initialize variable
   second=10; //Initialize variable

   add = first + second; //add values and store output to 'add' variable
   subtract = first - second; /*subtract values and store output to 'subtract' variable */
   multiply = first * second; //store output to 'multiply' variable

   printf("Sum = %d\n",add); //print value of add
   printf("Difference = %d\n",subtract); //print value of subtract
   printf("Multiplication = %d\n",multiply); //print value of multiply
   getch(); //Waits for user input

The Output for this Program will be


Sum = 32
Difference = 12
Multiplication = 220

In this simple C program we can do some modifications to check for smaller number and then do the subtraction from large number, we will do that in next program.

You can also Mathematics C Program to use it, and let me know if you face any issue with this program by leaving a comment below.

0 Responses on A Simple C Program for Mathematical Calculation|

Leave a Message

Your email address will not be published. Required fields are marked *

CommentLuv badge

Pin It on Pinterest