C program to find subtraction of two integer number

In this C program, we are going to read two integers numbers and find subtraction of given numbers.
Submitted by Manju Tomar, on November 07, 2017

Problem statement

Given two integer number and find the subtraction of them using C program.

In this program, we are reading two integer numbers in variable a and b and assigning the subtraction of a and b in the variable sub.

Example 1:

Input number 1: 40
Input number 2: 45
Output: -5

Example 2:

Input number 1: 45
Input number 2: 40
Output: 5

Program to find subtraction of two numbers in C


int main()
	int a,b,sub;

	//Read value of a
	printf("Enter the first no.: ");

	//Read value of b
	printf("Enter the second no.: ");

	//formula of subtraction
	sub= a-b;
	printf("subtract is = %d\n", sub);

	return 0;


First run:
Enter the first no.: 40
Enter the second no.: 45
subtract is = -5

Second run:
Enter the first no.: 45
Enter the second no.: 40
subtract is = 5

Since, this is a very simple program for beginners, still you liked the program and its explanation, please share your comments.

C Basic Programs »

Related Programs

Comments and Discussions!

Load comments ↻

Copyright © 2024 www.includehelp.com. All rights reserved.