CDeveloperHow-To

Subtract two numbers in C (with algorithm)

By Jul 6, 2013 No Comments

In my previous post, I wrote about Adding two numbers in C. Let’s learn how to subtract two numbers in C this time. It is very simple and similar to Adding two numbers in C. Let’s begin to subtract two numbers in C. If you are unsure about any part and more information, put it down in the comments section below or look it up on Google for a quick response.  We will try to get back to you as soon as we see the comment.

Download the source code:

Download Program

Algorithm to subtract two numbers in C:

1) Start

2) Accept Number one

3) Accept Number two

4) Subtract both the numbers

5) Print the result.

6) End

Program to subtract two numbers in C:

/*Program to subtract two numbers in C.
Programmer: Harsh Shah, Date: 29/6/13*/
#include<stdio.h>
#include<conio.h>

void main(){

int one, two, sub;

printf("Enter first number - ");

scanf("%d",&one);

printf("Enter second number - ");

scanf("%d",&two);

sub = one - two;

printf("The subtraction of numbers %d and %d is %d",one,two,sub);

getch();

}

//End of the program.

Output:

Enter first number – 22

Enter second number – 11

The subtraction of numbers 22 and 11 is 11

So this was, the program to subtract two numbers in C.

Download Code

Download Program

Read Also:

Introduction to C Programming

Adding two numbers in C

Multiplying two numbers in C

Dividing two numbers in C

Harsh Shah

Harsh Shah

Geek, Tech Crazy, Wannabe Entrepreneur, Blogger, Freelancer, Noob

Leave a Reply