Programs in JAVA to get the remainder and quotient of given two numbers without using % and / operators?
Answer Posted / swap1710
import java.util.*;
class WithoutO
{
public static void main(String args[])
{
int res,rem=0,num,div,qu=0;
Scanner s=new Scanner(System.in);
System.out.println("Enter number:");
num=s.nextInt();
System.out.println("Enter divisor:");
div=s.nextInt();
for(int i=1;i<num;i++)
{
res=div*i;
if(res>num)
{
res=res-div;
qu=i-1;
rem=num-res;
break;
}
}
System.out.println("Quotient:" +qu);
System.out.println("Remainder:" +rem);
}
}
/*
Output
D:Javap>java WithoutO
Enter number:
92
Enter divisor:
4
Quotient:23
Remainder:0
*/
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Given a cube of size n*n*n (i.e made up of n^3 smaller cubes), find the number of smaller cubes on the surface. Extend this to k-dimension.
What r the attributes using in Win Runner?
How to call a C++ function which is compiled with C++ compiler in C code?
why we use abstract word in abstract window toolkit in java language.
4. What is the need of START 0? Instead if can we use any other numeric? If we use what will happen?
Write a program to find factorial of a number using functions
What is ur porject Architecture? If anyone ask what i have to specify here..
What for decision coverage and modified condition decision coverage are used? Wat is the difference between them?
what is the difference between SCAN AND CHECK,LOKUP AND XFOOT? where we can use thease opcodes? Can any body tell me real time senariao with example?
what are all the validation we need to perform in data stage?
without selecting individually each field in Action Class from jsp,what is the best process to select as many as field at a time automatically from jsp page by using value object class.
what are the advantages of sap on other software ?
write a query that returns one row for each department and the number of employees in that department. Given two tables EMPLOYEE and DEPARTMENT, where there can be multiple employees per department.
Do not use more than 3 nested IF. Use Evaluate statement in case of more IF required. Please give a detail explantion besides readability and clarity for Evaluate stmt.
What is the entry point function of a DLL?