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
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.
how do find the user exit for selected feild whatis the process and can u plz explain it
Given a Binary Search Tree, write a program to print the kth smallest element without using any static/global variable. You can?t pass the value k to any function also.
Given an array of size n. It contains numbers in the range 1 to n. Find the numbers which aren?t present.
Is the IT field raise again? What is the position of IT after 4 years?
hoe to data grid use in sql server 2000?
what is the meaning of without standing arrears?
How to print No.of.rows affected after updation using ADO.Net
< No Frames > tag is used for
what is c sharp dotnet
1.what is the vesition managment.
what is the difference between an OS(operating system) and Framework?
what are importance in problem tracking
1. Write a program to create a sentence at runtime and count number of vowels in it ? 2. Write a program to get a string and to convert the 1st letter of it to uppercase ?
Diffrence between 2.0,3.0,3.5,4.0. versions of .net?