Home / Programs / Program to find subtraction of two numbers using c programming language
🚀 Programming Example

Program to find subtraction of two numbers using c programming language

👁 5,621 Views
💻 Practical Program
📘 Step Learning

In this example, the user is asked to enter two integers. Then, we we will subtract from one variable from another and displayed on the screen.

Flow chart

Program to find subtraction of two numbers
Figure:

To understand this example, you should have the knowledge of the following C programming topics:

  • C Data Types
  • C Variables, Constants and Literals
  • C Input Output (I/O)
  • C Programming Operators

💻 Program Code

#include"stdio.h" 
 void main()
	{
        // variable declaration
	int num1, num2, subResult; 

	printf("Enter two no: ");
 	scanf("%d%d",&num1,&num2);
	subResult = num1 - num2;

       // Print result
       printf("subtraction result =%d \n", subResult);
    
}
                        

🖥 Program Output

Enter two no: 6 3
sum=3
Press any key to continue . . .
                            

📘 Explanation

Algorithm:

  • Step 1: Start
  • Step 2: Declare variable number 1, number 2 and subResult
  • Step 3: Read Variable number 1, number 2
  • Step 4: Perform operation (subResult = num1 - num2)
  • Step 5: Print subResult variable
  • Step 7: Stop
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.