Simple Subtraction Progarm in C Programming

Algorithm


  1. Take Three Variable, number1, number2, summation.
  2. Assign values on number1 and number2.
  3. Make subtraction= number2 - number1.
  4. Print subtraction value.

Code Examples

# 1 Basic Simple Subtraction Program

Code - C Programming

#include <stdio.h>
int main(){
  int subtraction = 0;
  int number1 = 10;
  int number2 = 20;
  subtraction = number2 - number1;
  printf("Subtraction = %d",  subtraction );
  return 0;
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
Subtraction = 10

#2 Subtraction Code Example with Input

Code - C Programming

#include <stdio.h>
int main(){
  int subtraction = 0, number1, number2;
 printf("Enter Number 2: ");
  scanf("%d", &number2);
  printf("Enter Number 1: ");
  scanf("%d", &number1);
  subtraction = number2 - number1;
  printf("Subtraction = %d\n",  subtraction );
  return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
20 10

Output

x
+
cmd
Subtraction = 10

Demonstration


Simple Subtraction Progarm in C Programming Example.

First Take three variables - number1, number2 and subtraction.

Then apply the simple algorithm for subtraction program - 

subtraction = number2 - number1;

 

That's the basic subtraction program