Home / Programs / Program to find division of two numbers.
Programming Example

Program to find division of two numbers.

👁 3,947 Views
💻 Practical Program
📘 Step by Step Learning

In this program we will show you how to divide one number with another. Take two variable number1 and number1 and use division operator (/) to divide them and store it in another variable divResult, finally print the divResult variable using printf function to see the result.

Flow chart

Division flow chart
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()
	{
	int number1, number2, divResult; 

	printf("Enter two no: ");
 	scanf("%d%d",&number1,&number2);

	divResult = number1 / number2;

        printf("Division result=%d \n", divResult);
    
}

Output

Enter two no: 10 2
Division result=5
Press any key to continue . . .

Explanation

Algorithm

  • Step 1: Start
  • Step 2: Declare variable number1, number2 and divResult
  • Step 3: Read Variable number 1, number 2
  • Step 4: Perform operation (divResult = number1/ number2)
  • Step 5: Print divResult variable
  • Step 7: Stop

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.