# Division between two numbers

Variables:

integers: number1 and number2 to hold values of number A and number B. division variable is used to hold the result of A / B

Functions:

printf() : is used to display something on the console/screen. %d in printf function is used to display an int variable on screen. \n is used to add a newline

scanf(): is used to fetch data inputted by the user on the console/screen using the keyboard. %d in scanf is indicated that inputted text is of type int. &num1 refers to the address of memory location which will hold number1

Note: As a result of A/B is stored as in an int variable, decimal places will be rounded.

Description: Slash / is the division operator used to get the division of two numbers. division variable holds the result of number1 divided by number2.

``````/*
* 1000+ C programs + tutorials
*
* This is a C program to Divide two
* numbers.
*
*
*
* 3_divide_two_numbers.c
*
*  Created on: Oct 20, 2014
*      Author: Code2care.org
*/

#include <stdio.h>
//#include <conio.h>

void main() {

int number1;
int number2;
int division;

//clrscr();
printf("Program to Divide of two numbers :  \n\n");

printf("Enter value of 1st number : ");
scanf("%d", &number1);

printf("\n\nEnter value of 2st number : ");
scanf("%d", &number2);

division = number1 / number2;

printf("\n\nDivision : %d / %d = %d", number1, number2, division);

//getch();

}``````
Output:
``````Program to Divide of two numbers :
Enter value of 1st number :
Enter value of 2st number :
Division : 10 / 5 = 2``````

If you do not want a 3rd variable division then we can simply output the result as,

printf("\n\n Sum of %d + %d = %d", numberA, numberB, numberA/numberB);

``````/*
*
* 1000+ C programs + tutorials
*
* Divide of two numbers without using third variable
*
*
*
* 3_divide_of_two_numbers.c
*
*  Created on: Oct 20, 2014
*  Author: Code2care.org
*/

#include <stdio.h>
//#include <conio.h>

void main() {

int numberA;
int numberB;

//clrscr();

printf("C Program to Divide of two numbers :  \n\n");

printf("Enter value of number A : ");
scanf("%d", &numberA);

printf("\n\nEnter value of number B : ");
scanf("%d", &numberB);

printf("\n\n nDivision of %d / %d = %d", numberA, numberB, numberA / numberB);

//getch();

}``````
Output:
``````C Program to Divide two numbers :
Enter value of number A : 4
Enter value of number B : 2
Division of 4 / 2 = 2``````

The best way to learn C programming is to practice more and more programs. Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.

BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.