Translate

Sunday, January 19, 2014

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

# include #include
int pow2(float );
void main()
{
int i,flag;
clrscr();
printf("En ter 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);
}

No comments:

Post a Comment

ग़ज़ल

rizw4nkh4n *ख़ुलूस-ए-दिल = purity of heart *एहतराम = आदर, सम्मान *मिज़ाजपुरसी = हाल-चाल पूछना *बाम = घर में सबसे ऊपर का कोठा और छत *इक़राम =...