Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Function to find the given number is a power of 2 or not?

Answer Posted / sagar bhagat

#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,flag=0,temp;
clrscr();

printf("\nEnter the number=");
scanf("%d",&num);

if(num<=0)
printf("Plz enter anoter num");
else
{
temp=num;
for(i=1;(i<num) ;i++)
{
if((i*i)==temp)
{
flag=1;
break;
}
}
}
if(flag==1)
printf("\nNumber %d is in power of 2 of %d",num,i);
else
printf("\nNumber %d is not in power of 2 ",num);

getch();
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do you have any idea about the use of "auto" keyword?

1135


if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0

2019


What standard functions are available to manipulate strings?

1213


What is main () in c language?

1191


How do you initialize pointer variables?

1156


What are extern variables in c?

1044


How can you determine the size of an allocated portion of memory?

1365


What is register variable in c language?

1070


why wipro wase

2374


Explain which function in c can be used to append a string to another string?

1143


What is #pragma statements?

1165


program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

3155


Subtract Two Number Without Using Subtraction Operator

911


typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?

1690


What are the primitive data types in c?

1136