Problem statement:- Program Division Two Numbers Operator without using Division(/) operator.
Input Data:- num1,num2
Output Data:-div
Program in C
Here is the source code of the C Program Division Two Numbers Operator without using Division(/) operator.
#include <stdio.h>
int main ()
{
int num1,num2;
printf("Enter the first number\n");
scanf("%d",&num1);
printf("Enter the second number\n");
scanf("%d",&num2);
int div=0;
while(num1>=num2)
{
num1=num1-num2;
div++;
}
printf("Division of two number is %d",div);
}
Input/Output:int main ()
{
int num1,num2;
printf("Enter the first number\n");
scanf("%d",&num1);
printf("Enter the second number\n");
scanf("%d",&num2);
int div=0;
while(num1>=num2)
{
num1=num1-num2;
div++;
}
printf("Division of two number is %d",div);
}
Enter the first number
10
Enter the second number
2
Division of two number is 5
Program in C++
Here is the source code of the C++ Program Division Two Numbers Operator without using Division(/) operator.
#include <iostream>
using namespace std;
int main ()
{
int num1,num2;
cout<<"Enter the first number\n";
cin>>num1;
cout<<"Enter the second number\n";
cin>>num2;
int div=0;
while(num1>=num2)
{
num1=num1-num2;
div++;
}
cout<<"Division of two number is "<<div;
}
Input/Output:using namespace std;
int main ()
{
int num1,num2;
cout<<"Enter the first number\n";
cin>>num1;
cout<<"Enter the second number\n";
cin>>num2;
int div=0;
while(num1>=num2)
{
num1=num1-num2;
div++;
}
cout<<"Division of two number is "<<div;
}
Enter the first number
300
Enter the second number
3
Division of two number is 100
Program in Java
Enter the first number:
25
Enter the second number:
5
Division of two number is 5
Here is the source code of the Java Program Division Two Numbers Operator without using Division(/) operator.
import java.util.Scanner;
public class DivisionWithoutDivisionSign {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
int num1,num2;
System.out.println("Enter the first number:");
num1=cs.nextInt();
System.out.println("Enter the second number:");
num2=cs.nextInt();
int div=0;
while(num1>=num2)
{
num1=num1-num2;
div++;
}
System.out.println("Division of two number is "+div);
cs.close();
}
}
Input/Output:public class DivisionWithoutDivisionSign {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
int num1,num2;
System.out.println("Enter the first number:");
num1=cs.nextInt();
System.out.println("Enter the second number:");
num2=cs.nextInt();
int div=0;
while(num1>=num2)
{
num1=num1-num2;
div++;
}
System.out.println("Division of two number is "+div);
cs.close();
}
}
Enter the first number:
25
Enter the second number:
5
Division of two number is 5
Program in Python
Enter first number:48
Enter second number:8
Division of two number is 6
Here is the source code of the Python Program Division Two Numbers Operator without using Division(/) operator.
num1=int(input("Enter first number:"))
num2=int(input("Enter second number:"))
div=0
while num1>=num2:
num1=num1-num2
div+=1
print("Division of two number is ",div)
Input/Output:num2=int(input("Enter second number:"))
div=0
while num1>=num2:
num1=num1-num2
div+=1
print("Division of two number is ",div)
Enter first number:48
Enter second number:8
Division of two number is 6
Most Recommend Questions:-
More Questions:-
0 Comments
Please do not Enter any spam link in the comment box