Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

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.

1067


What r the attributes using in Win Runner?

2372


How to call a C++ function which is compiled with C++ compiler in C code?

1262


why we use abstract word in abstract window toolkit in java language.

2152


4. What is the need of START 0? Instead if can we use any other numeric? If we use what will happen?

2309


Write a program to find factorial of a number using functions

1651


What is ur porject Architecture? If anyone ask what i have to specify here..

1903


What for decision coverage and modified condition decision coverage are used? Wat is the difference between them?

2113


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?

2513


what are all the validation we need to perform in data stage?

2368


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.

1827


what are the advantages of sap on other software ?

2121


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.

1553


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.

1926


What is the entry point function of a DLL?

1010