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

Answer Posted / siva prabhu

#include<stdio.h>

int main()
{
int x,y,i=0,j=0,r=0;
printf("enter a num\n");
scanf("%d",&x);

if(x>3)
{
while(x>0)
{
i=0;
while(i<3)
{
--x;
++i;
}
++j;
if(x<3)
{
r=x;
printf("reminder is %d\n",x);
break;
}
}
if(r==0)
printf("the given is divisible by 3\n");
else
printf("the given no. is not %% by %3\n");
}
else
{
printf("the given no. is not %% by %3\n");
}
return 0;
}

Is This Answer Correct ?    10 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is time complexity c?

570


What is the difference between Printf(..) and sprint(...) ?

792


What are the Advantages of using macro

688


What does %2f mean in c?

676


How to delete a node from linked list w/o using collectons?

2091






What is scope and lifetime of a variable in c?

581


why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above

656


What are two dimensional arrays alternatively called as?

664


What are the advantage of c language?

554


What is a dynamic array in c?

599


write a program to rearrange the array such way that all even elements should come first and next come odd

1766


How do you print only part of a string?

618


#include { printf("Hello"); } how compile time affects when we add additional header file .

1427


In C programming, what command or code can be used to determine if a number of odd or even?

627


What does c mean?

591