In my previous post, I wrote about Multiplying two numbers in C. We are doing a too much of simple math here. Let’s code a program to divide two numbers in C. Now to divide two numbers in C, we just have to use the “/” operator instead of other math operators we used before. If you are unsure about any part and more information, put it down in the comments section below or look it up on Google if you want quick response. We will try to get back to you as soon as we see the comment.
Download the source code:
Download ProgramAlgorithm to divide two numbers in C:
1) Start
2) Accept Number one
3) Accept Number two
4) Divide both the numbers
5) Print the result.
6) End
Program to divide two numbers in C:
/*Program to divide two numbers in C. Programmer: Harsh Shah, Date: 29/6/13*/ #include<stdio.h> #include<conio.h> void main(){ int one, two, div; printf("Enter first number - "); scanf("%d",&one); printf("Enter second number - "); scanf("%d",&two); div = one / two; printf("The divison of numbers %d and %d is %d",one,two,div); getch(); } //End of the program.
Output:
Enter first number – 22
Enter second number – 11
The divison of numbers 22 and 11 is 2
So this was, the program to add two numbers in C.