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 are the types of functions in c?
Multiply an Integer Number by 2 Without Using Multiplication Operator
Difference between MAC vs. IP Addressing
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
pierrot's divisor program using c or c++ code
What is a keyword?
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values
When can a far pointer be used?
Is c dynamically typed?
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
What does emoji p mean?
explain what are pointers?
program for reversing a selected line word by word when multiple lines are given without using strrev
What are two dimensional arrays alternatively called as?
What is volatile variable in c?