Q:

Write a C program to find subtraction of two integer number

0

C program to find subtraction of two integer number

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program to find subtraction of two numbers in C

#include<stdio.h>

int main()
{
	int a,b,sub;

	//Read value of a
	printf("Enter the first no.: ");
	scanf("%d",&a);

	//Read value of b
	printf("Enter the second no.: ");
	scanf("%d",&b);

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

	return 0;
}

Output

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C programming Basic Input, Output, if else, Ternary Operator based Programs

Similar questions


need a help?


find thousands of online teachers now
Write a C program to find SUM and AVERAGE of two ... >>
<< Write a C program to print Hello World...