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 the symbol indicated the c-preprocessor?
What is structure packing in c?
Do pointers store the address of value or the actual value of a variable?
What is the difference between fread buffer() and fwrite buffer()?
Write a program to check palindrome number in c programming?
What is the best style for code layout in c?
What is the difference between Printf(..) and sprint(...) ?
What are the key features in c programming language?
Is struct oop?
How macro execution is faster than function ?
Do you have any idea about the use of "auto" keyword?
What is the difference between printf and scanf in c?
Why main function is special give two reasons?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
How do I get an accurate error status return from system on ms-dos?