Given an unsigned integer, find if the number is power of 2?
Answer Posted / sagar shah
#include<stdio.h>
main()
{
int i,n,r=2
clrscr();
scanf("%d",&n);
for(i=1;i<=n;i=r*i)
{
if(i==n)
{
r=0;
break;
}
}
if (r==0)
{
printf("power of two:");
}
else
{
printf("not power of two:");
}
getch();
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Who developed c language and when?
What is the difference between abs() and fabs() functions?
What is uint8 in c?
Is fortran still used today?
What is an array? What the different types of arrays in c?
if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.
Explain what are bus errors, memory faults, and core dumps?
What does double pointer mean in c?
Explain 'bus error'?
How can I insert or delete a line (or record) in the middle of a file?
What are compound statements?
about c language
Are comments included during the compilation stage and placed in the EXE file as well?
What is anagram in c?
explain what are actual arguments?