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
What is the difference between mpi and openmp?
What does node * mean?
In which language linux is written?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
Is that possible to add pointers to each other?
Is file a keyword in c?
What are conditional operators in C?
What does %c mean in c?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
Explain the difference between ++u and u++?
What is a const pointer in c?
What is a pragma?
Why does the call char scanf work?
Is c programming hard?
What is equivalent to ++i+++j?