# Without using /,% and * operators. write a function to divide a number by 3.

#### sarathi trichy Profile Answers by sarathi trichy

• Nov 29th, 2007

#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
float j=0;
clrscr();
printf("enter the no");
scanf("%d",&n);
for(i=n;i>2;i=i-3)
{
j=j+1;
if(i==4)
{
j=j+1.333333;
}
if(i==5)
{
j=j+1.666666;
}
}
printf("%f",j);

getch();

}

#### purnendu_patra Profile Answers by purnendu_patra

• Dec 11th, 2007

The number is N, the decimal places to which the division will be done is  D.

int quot=0,remainder=0,rem=0;

int x=0;

Void DivisionBySubtraction(N,D)
{
while(N>=3)

{

N-=3;

++quot;

}

if (N==0)

cout<<"quotient="<<quot;

else

{

while(x<D)

{

N*=10;

while(N>=3)

{  N-=3;

rem++;

}

remainder = remainder*10+rem;

if (N==0)
break;
++x;
}
}

cout<<"remainder="<<remainder;

}

#### gayandevi Profile Answers by gayandevi

• Jul 15th, 2008

Can we use logarithm."logarithm of a number-logarithm of 3".Taking antilog gives the result

• Sep 10th, 2009

void dvdby3(int n)
{
int count=0,rem;
while(n>0)
{
rem=n;//reminder
n=n-3;
count++;
}
}

#### saipk Profile Answers by saipk

• Dec 9th, 2010

quo=-1;rem=0;
//n the number entered
for(i=0;i<=n;i+=3)
{
quo+=1;
}
rem=n-i+3;
printf("%d is the quotient n%d is the remainder",quo,rem);

#### Satish Anjaneyappa Profile Answers by Satish Anjaneyappa

• Apr 8th, 2011

int quoitent=-1, rem=0;

int number;

while(number>=0)
{
rem=number;
quoitent +=1;   //quoitent= quoitent+1;
number -=3;   //number=number-3;

#### Alok Mishra

• Aug 4th, 2011

{geshibot language="c"}#include
#include
void main()
{
int i,n;
float m,j=0;
clrscr();
printf("enter the no");
scanf("%d",&n);
if(n==1)
{
m=0.3333;
printf("%f",m);
}
if(n==2)
{
m=0.6666;
printf("%f",m);
}
if(n >= 3)
{
for(i=n;i>2;i=i-3)
{
j=j+1;
if(i==4)
j=j+1.333333;
if(i==5)
j=j+1.666666;
}
printf("%f",j);
}
getch();
}
}{/geshibot}

Send   Reset