Enter your email address:


Monday, September 2, 2013

Home » , » WAP to find out if a given number is a power series of 2 or not,withou t any loop and without using % modulo operator.

WAP to find out if a given number is a power series of 2 or not,withou t any loop and without using % modulo operator.

Questions: Top-30-c-programs-asked-in-interview_6304.html

30. WAP to find out if a given number is a power series of 2 or not,withou t any loop and without using % modulo operator.

#include
#include
int pow2(float );
void main()
{
int i,flag;
clrscr();
printf("Enter the number\n") ;
scanf("%d" ,&i);
flag=pow2( i);
if(flag)
printf("\n %d is power series of 2",i);
else
printf("\n %d is not a power series of 2",i);
getch();
}

int pow2(float j)
{
static float x;
x=j/2;
if(x==2)
return 1;
if(x
return 0;
x=pow2(x);
}
Share this games :

0 comments:

Post a Comment

Related Posts