Division
OF TWO NUMBERS
SIMPLE CPP LANGUAGE CODE FOR DIVISION OF TWO NUMBERS:
#include<iostream.h>
#include<conio.h>
void main()
{
int a, b, c;//we take two integer
value
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to accept number
c=a/b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch();
}
And save with extension .cpp
for eg.
DIV.cpp// DIV is the name of the file and .cpp is extension of file.
In the above example, we can divide integer numbers not fractional numbers. For example when output screen comes type two numbers like 9 and press enter then type next numbers like 3 then press enter the answer will be displayed on the output screen.
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to accept number
c=a/b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch();
}
And save with extension .cpp
for eg.
DIV.cpp// DIV is the name of the file and .cpp is extension of file.
In the above example, we can divide integer numbers not fractional numbers. For example when output screen comes type two numbers like 9 and press enter then type next numbers like 3 then press enter the answer will be displayed on the output screen.
---------------------------------------------------------------------------------------
OUTPUT:
Enter the number: 9
3
Ans=3
This code is for integer numbers if you want to divide fractional numbers then in above code small changes is there i.e.in the place of int type float. For Division of fractional numbers the code is as follow:
DIVISION OF TWO FRACTIONAL NUMBERS:
#include<iostream.h>
#include<conio.h>
void main()
{
float a, b, c;//we take two
fractional value
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to accept number
c=a/b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch ();
}
cout<<"Enter the number :";//use to print the letter, character
cin>>a>>b;//use to accept number
c=a/b;//arithmetic logical operation, formula
cout<<"Ans="<<c; /*use to perform operation and display answer*/
getch ();
}
OUTPUT:
Enter the number: 5.97
6.73
Ans=0.8870
I hope you like my blog so if any queries are there then write in the comment box. I will solve it. Friends in the next blog I will teach you another program.
I hope you like my blog so if any queries are there then write in the comment box. I will solve it. Friends in the next blog I will teach you another program.
CPP code for Division of two numbers
Reviewed by Amit Waghmare
on
July 07, 2019
Rating:
No comments: