Â
In this, we are going to see how to divide two numbers with the help of C++ program.
The Code given below can be used in Turbo C++ Compiler.
// Division of two numbers
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a = 65;
int b = 21;
int c = a / b;
int d = b / a;
cout<<"Division of a by b is : "<<c<<endl;
cout<<"Division of b by a is : "<<d<<endl;
// Float division :
float e = float(a) /b;
float f = float(b) /a;
cout<<"Float Division of a by b is : "<<e<<endl;
cout<<"Float Division of b by a is : "<<f<<endl;
// if you try to do (any number) / 0 then the compiler will show warning: division by zero [-Wdiv-by-zero]
// try this your self :
// cout<<(3/0);
getch();
}
// Division of two numbers
#include<iostream>
using namespace std;
int main()
{
int a = 65;
int b = 21;
int c = a / b;
int d = b / a;
cout<<"Division of a by b is : "<<c<<endl;
cout<<"Division of b by a is : "<<d<<endl;
// Float division :
float e = float(a) /b;
float f = float(b) /a;
cout<<"Float Division of a by b is : "<<e<<endl;
cout<<"Float Division of b by a is : "<<f<<endl;
// if you try to do (any number) / 0 then the compiler will show warning: division by zero [-Wdiv-by-zero]
// try this your self :
// cout<<(3/0);
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP