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
What is time complexity c?
What is the difference between Printf(..) and sprint(...) ?
What are the Advantages of using macro
What does %2f mean in c?
How to delete a node from linked list w/o using collectons?
What is scope and lifetime of a variable in c?
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
What are two dimensional arrays alternatively called as?
What are the advantage of c language?
What is a dynamic array in c?
write a program to rearrange the array such way that all even elements should come first and next come odd
How do you print only part of a string?
#include
In C programming, what command or code can be used to determine if a number of odd or even?
What does c mean?