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...

write a program to find a given no. is divisible by 3 or not
without using any arthimetic operators?

Answer Posted / sanjay bhosale

#include<stdio.h>
int main()
{
int x=0,y=-3;
printf("\n Enter the number :\t");
scanf("%d",&x);
int xor, and, temp,tempvar=x;
x = (x>0) ? x:(-x);
while(x>0)
{
and = x & y;
xor = x ^ y;
while(and != 0 )
{
and <<= 1;
temp = xor ^ and;
and &= xor;
xor = temp;
}
x = xor;
}
if(x==0)
printf("%d is divisible by 3",tempvar);
else
printf(" %d is not divisible by 3",tempvar);
return 0;
}

Is This Answer Correct ?    11 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is sizeof a keyword in c?

964


What are directives in c?

970


What is the difference between arrays and pointers?

1121


Compare array data type to pointer data type

1018


What are the advantages and disadvantages of c language?

1013


How can I manipulate strings of multibyte characters?

1109


the question is that what you have been doing all these periods (one year gap)

2078


A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference

1105


how to write optimum code to divide a 50 digit number with a 25 digit number??

3267


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

1088


Explain heap and queue.

1076


What is the code for 3 questions and answer check in VisualBasic.Net?

2154


What is null in c?

1085


What is a list in c?

1027


How does sizeof know array size?

1113