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

How many bytes are occupied by near, far and huge pointers (dos)?

665


How was c created?

586


What are directives in c?

539


1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.

2333


Explain Basic concepts of C language?

640






What is the difference between malloc() and calloc() function in c language?

597


Is c is a procedural language?

594


Can you please explain the scope of static variables?

597


What is #include stdlib h?

612


How is a pointer variable declared?

588


code for find determinent of amatrix

1512


How can you increase the size of a statically allocated array?

608


Do you know the difference between exit() and _exit() function in c?

606


Can we use visual studio for c?

544


When should you not use a type cast?

656