C Program to Perform All Arithmetic Operations

Hello coders, in this post we will how to write C Program to perform all arithmetic operations. This is a very basic C program.

As you already know that this site does not contain only c programming solutions here, you can also find the solution for other problems. I.e. Web Technology, Data StructuresRDBMS ProgramsJava Programs Solutions,  Fiverr Skills Test answersGoogle Course AnswersLinkedin AssessmentLeetcode Solutions, and Coursera Quiz Answers.

C Program to perform all arithmetic operations
C Program to perform all arithmetic operations

if you want to learn C programming free of cost please visit:

C Program to perform all arithmetic operations

#include <stdio.h>

void main()
    int num1, num2;
    int sum, diff, mul, div, mod, quo;

    printf("Enter first number: ");
    scanf("%d", &num1);
    printf("Enter second number: ");
    scanf("%d", &num2);

    sum = num1 + num2;
    diff = num1 - num2;
    mul = num1 * num2;
    mod = num1 % num2;
    quo = num1 / num2;

    printf("Sum = %d\n", sum);
    printf("Difference = %d\n", diff);
    printf("Multiply = %d\n", mul);
    printf("Modulus = %d\n", mod);
    printf("Quotient = %d\n", quo);


Enter first number: 30
Enter second number: 10
Sum = 40
Difference = 20
Multiply = 300
Modulus = 0
Quotient = 3

C Program to perform all arithmetic operations using function

// C Program to Perform Arithmetic Operations Using Functions
#include <stdio.h>

// Declaring addition function
int addition(int a, int b){
    int sum = a + b;
    return sum;

// Declaring subtraction function
int subtract(int a, int b){
    int difference = a - b;
    return difference;

// Declaring multiplication function
int multiply(int a, int b){
    int multiply = a * b;
    return multiply;

// Declaring division function
float division(float a, float b){
    float divide = a / b;
    return divide;

// Declaring modulus function
float mod(int a, int b){
    int rem = a % b;
    return rem;

int main(){
    int num1, num2;
    // Asking for input
    printf("Enter the first number: ");
    scanf("%d", &num1);
    printf("Enter the second number: ");
    scanf("%d", &num2);
    // Displaying output
    printf("Arithmetic operations on %d and %d: \n", num1, num2);
    printf("Addition: %d\n", addition(num1, num2));
    printf("Subtraction: %d\n", subtract(num1, num2));
    printf("Multiplication: %d\n", multiply(num1, num2));
    printf("Division: %f\n", division(num1, num2));
    printf("Modulus: %d\n", mod(num1, num2));
    return 0;
Enter the first number: 20
Enter the second number: 10
Arithmetic operations on 20 and 10: 
Addition: 30
Subtraction: 10
Multiplication: 200
Division: 2.000000
Modulus: 10


I hope after going through this post, you understand how to write a C Program to perform all arithmetic operations, if there is any case program is not working and showing an error please let me know in the comment section.

Sharing Is Caring

Leave a Comment