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
Can include files be nested?
Are there namespaces in c?
How can you convert integers to binary or hexadecimal?
What is wrong with this initialization?
Why is this loop always executing once?
Should a function contain a return statement if it does not return a value?
List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.
What is infinite loop?
What is the use of parallelize in spark?
Is main is user defined function?
What is structure padding in c?
WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.
What is putchar() function?
How many header files are in c?
Can you write the algorithm for Queue?