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
Wrtite a JCL for sorting a file with start from 36 postion lenth 9 excluding a num eq to 98768. for 3 marks mainframe
What is test execution and when will we start execution please send me one example for this question
How do you initialize a static member of a class with return value of some function?
what is the certificates in biztalk?
hi This is radhika.Can anyone help me to know the question papers of NATIONAL INFORMATICS CENTRE for the post of scientific officer/engineer? if anyone know plz tell me question paper pattern
what is programmable BIST in today ic design
what is the similarity between networking devices?
8.In DSP,Define Signal and System?and various type of signals.
Hello...has anyone interviewed with Information Management Services(IMS)located in Silver Spring MD??If yes,what can you share about the programming test and the analytical test?
Mainly Related to Oracle, DBMS , Oracle Stored Procedures, Functions, Oracle 9i Architecture, Redo logs..., Views,
what is the difference between rename and label
Write a shell program where you enter a number which corresponds to K.M. Find out the corresponding values in m, cm, inches, and feet. Hints:- 1 k.m= 1000 m 1 m= 100 cm 1 inches= 2.54 cm. 1 feet= 12 inches
hai i am prasanna.I am MCA 2009 fresher.tell me about certifications.which certification helps me to improve my carrier and to get a technically oriented job ,which certification helps to get job faster.
which book we learned this mantis? how many version are realsed this mantis upto now?
1.what is the vesition managment.