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

hi i m deepak my shedule for NIC pi is 17 Apr please contact me if anybody has interview on same day or give me some idea who have faced

1976


WHAT IS MAIN IMPORTANT THING IN SOFTWARE?

2226


How to set fixed width in particular in html? if i type more character in this it will not push near . this is my question. can u tell me the answer...

2505


Given a set. Write the pseudo code to get all the subsets for the given set. Eg. Input : {1,2} Output : (),(1),(2),(1,2)

2631


what is the work of 1tier,2tier,&ntier? Plz Explain it!

2414


in cobol,wat is the difference in using 'set index in occurs clause' ....and 'occurs depending-on clause'

2173


what are the differences between CONS, LIST, and APPEND

5277


shall we execute our java programmes in jre

2191


How can we develop a multi-tier application in Java?

1845


what is the certificates in biztalk?

1853


Where do we need Operator overloading?

1065


Please describe an example where you used object orientation in one of your programs.

1910


When you deliver your C++ headers and C++ library of a class (what all can you change in the class so that application using your class does not need to recompile the code)

1127


Display names and numbers of employees who have 5 years or more experience and  salary less than Rs.15000 using array of structures (name, number, experience and  salary)

4697


3 members in a pf.how we read 3 members without using ovrdbf.using rg pgms....

2210