ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
program to get the remainder and quotant of given two 
numbers with out using % and / operators?
 Question Submitted By :: Anilkumar
I also faced this Question!!     Rank Answer Posted By  
 
  Re: program to get the remainder and quotant of given two numbers with out using % and / operators?
Answer
# 1
#include<stdio.h>
#include<conio.h>

int remainder, tempdevisor ,i = 0;

int division(int,int);

int main()
{
	int dividend, divisor;
	int quotient;

	printf("Enter the value of Dividend and Divisor\n");
	scanf("%d %d",&dividend,&divisor);

	tempdevisor = divisor;
	quotient = division(dividend,divisor);

	printf("The Quotient is %d\n",quotient);
	printf("The Remainder is %d\n",remainder);
}

int division(int dividend,int divisor)
{

	int quotient = 1;
	i++;

	if(dividend == divisor)
	{
		remainder = 0;
		return 1;
	}
	else if (dividend < divisor)
	{
		remainder = dividend;
		return 0;
	}

	while(divisor <= dividend)
	{
		divisor = divisor<<1;
        quotient = quotient<<1;
	}
	divisor = divisor>>1;
    quotient = quotient>>1;

  //  printf("Quotient in the %d iteration is %d\n",i,quotient);
	quotient = quotient + division(dividend-divisor,tempdevisor);

	return quotient;



}
 
Is This Answer Correct ?    5 Yes 3 No
Santhi Perumal
 
  Re: program to get the remainder and quotant of given two numbers with out using % and / operators?
Answer
# 2
# include <stdio.h>
# include <conio.h>
void main()
{
 
  unsigned int dividened,divisor,quotient=0,remainder;

  printf("\nenter a dividened");
  scanf("%d",&dividened);

  printf("\n  enter a divisor");
  scanf("%d",&divisor);

  while(dividened >divisor)
  {
	  
	  quotient++;
	  dividened=dividened-divisor;
 
  
  }
  if(dividened==divisor)
  { 
	  remainder=0;
	  quotient++;
  }
  else
  {   
	  remainder=dividened;
  }

  printf("\n quotient of %d / %d is %d",
(quotient*divisor+remainder),divisor,quotient);
  printf("\n remainder of %d / %d is %d",
(quotient*divisor+remainder),divisor,remainder);

  getch();
}
 
Is This Answer Correct ?    4 Yes 3 No
Babitha
 
 
 
  Re: program to get the remainder and quotant of given two numbers with out using % and / operators?
Answer
# 3
#include<stdio.h>
#include<conio.h>



int remainder;

void main()
{
	int dividend, divisor;
	int quotient;
	int division(int,int);

	printf("Enter the value of Dividend and Divisor\n");
	scanf("%d %d",&dividend,&divisor);

	
	quotient = division(dividend,divisor);

	printf("The Quotient is %d\n",quotient);
    printf("The Remainder is %d\n",remainder);
	
}

int division(int dividend,int divisor)
{

	int quotient=0,tempdivisor = divisor;


	if(dividend == divisor)
	{
		
		remainder=0;
		return 1;
	}
	else if (dividend < divisor)
	{
		
		remainder=1;
		return 0;
	}

	while(tempdivisor <= dividend)
	{
		tempdivisor = tempdivisor + divisor;
        quotient = quotient++;
	}
	remainder=dividend-(tempdivisor-divisor);


 
    	return quotient;



}
 
Is This Answer Correct ?    5 Yes 1 No
Venkat Raj
 
  Re: program to get the remainder and quotant of given two numbers with out using % and / operators?
Answer
# 4
#include <iostream>
using namespace std;
int main()
{
int a,b;
cout<<"enter two number"<<endl;
int r,q=0,bi,s;
cin>>a>>b;
if(a<b)
{
s=a;
bi=b;
}
else
{
s=b;
bi=a;
}
r=bi-s;
q++;
while(r>=s)
{
q++;
r=r-s;
}//endl of while.*/
cout<<"remainder is "<<r<<" quotient is "<<q<<endl;
return 0;
}
 
Is This Answer Correct ?    2 Yes 0 No
Mahfooz Alam
 
  Re: program to get the remainder and quotant of given two numbers with out using % and / operators?
Answer
# 5
#include <stdio.h>
#include<conio.h>

void main()
{
int a,b,a1,b1,rem=0;
scanf(“%d %d”,&a,&b);


if(a>b)
{
a1=a;
b1=b;
}
else
{
a1=b;
b1=a;
}
while(a1>=b1)
{
rem++;
a1-=b1;
}
printf(" remainder is %d  quotient is %d",rem,a1);
}
 
Is This Answer Correct ?    3 Yes 0 No
Kadher Masthan..,sit
 
  Re: program to get the remainder and quotant of given two numbers with out using % and / operators?
Answer
# 6
#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b,r1,r2,count=0;
 printf("Enter two numbers\n");
 scanf("&d,&d",a,b);
 if(a>b)
 {
  r1=a;
  r2=b;
 }
 else
 {
  r1=b;
  r2=a;
 }
 do
   {
    res=r1-r2;
    r1=res;
    count++;
   }
 while(r1>=r2);
 printf("the remainder is ",res);
 printf("the quotient is ",count);
}
 
Is This Answer Correct ?    0 Yes 1 No
Brad
 
  Re: program to get the remainder and quotant of given two numbers with out using % and / operators?
Answer
# 7
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,i,remaider,q;
i=0;
 printf("Enter two numbers\n");
 scanf("&d,&d",x,y);

do 
{
  x=x-y;
  i=i+1;
}while(x>=y)

if (x<y)
{
  remainder=x;
  q=i;
  
}
printf("the remainder is ",x);
 printf("the quotient is ",q);

}
 
Is This Answer Correct ?    0 Yes 1 No
Suma
 
  Re: program to get the remainder and quotant of given two numbers with out using % and / operators?
Answer
# 8
#include <stdio.h>

int main()
{
    int cDivident,cDivisor,cRemainder;

    printf("\nEnter Divident and Divisor :\n");
    while(!(scanf("%d %d",&cDivident,&cDivisor)))
    {
        printf("\nPlease Enter Integers!!!:");
        fflush(stdin);
    }
    cRemainder = cDivident;
    while ( cRemainder >= cDivisor)
    {
        cDivident = cDivident - cDivisor;
        cRemainder = cDivident;
    }

     printf("\nReminder = %d",cRemainder);
     return 0;
}
 
Is This Answer Correct ?    1 Yes 1 No
Mohammad Haris
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
#include<stdio.h> int fun(); int i; int main() { while(i) { fun(); main(); } printf("hello \n"); return 0; } int fun() { printf("hi"); } answer is hello.how??wat is tat while(i) mean? Intel4
how many header file is in C language ?  14
what is out put of the following code? #include class Base { Base() { cout<<"constructor base"; } ~Base() { cout<<"destructor base"; } } class Derived:public Base { Derived() { cout<<"constructor derived"; } ~Derived() { cout<<"destructor derived"; } } void main() { Base *var=new Derived(); delete var; } Honeywell2
How can I find out how much memory is available? Persistent1
printf("%d",(printf("Hello")); What it returns? TCS23
WHAT IS THE DIFFERANCE BITWIN GETS();AND SCANF();  2
how to impliment 2 or more stacks in a single dimensional array ? iFlex1
52.write a “Hello World” program in “c” without using a semicolon? 53.Give a method to count the number of ones in a 32 bit number? 54.write a program that print itself even if the source file is deleted? 55.Given an unsigned integer, find if the number is power of 2?  6
write a program to compare 2 numbers without using logical operators? IBM1
difference between my-strcpy and strcpy ? Geometric-Software3
for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????  6
5. What kind of sorting is this: SORT (k,n) 1.[Loop on I Index] repeat thru step2 for i=1,2,........n-1 2.[For each pass,get small value] min=i; repeat for j=i+1 to N do { if K[j]<k[min] min=j; } temp=K[i];K[i]=K[min];K[min]=temp; 3.[Sorted Values will be returned] A)Bubble Sort B)Quick Sort C)Selection Sort D)Merge Sort Accenture2
how to find a 5th bit is set in c program IBM3
which operator having lowest precedence?? a.)+ b.)++ c.)= d.)%  4
Is there any restriction in how many arguments printf or scanf function can take? in which file in my c++ compiler i can see the code for implementation of these two functions??  3
what is the difference between arrays and linked list Tech-Mahindra15
main() {char a[10]={1,2,3,4,5,6};int x; for(x=0;x<4;x++){ b[x]=x+'a';} printf("%s",b);}  3
How many ways are there to swap two numbers without using temporary variable? Give the each logic.  6
please give me some tips for the selection in TCS. TCS3
how do u find out the number of 1's in the binary representation of a decimal number without converting it into binary(i mean without dividing by 2 and finding out the remainder)? three lines of c code s there it seems...can anyone help  2
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com