52.write a “Hello World” program in “c” without using a
semicolon?
53.Give a method to count the number of ones in a 32 bit number?
54.write a program that print itself even if the source file
is deleted?
55.Given an unsigned integer, find if the number is power of 2?
Answer Posted / lokesh n. jaliminche
#include <stdio.h>
unsigned int check_power(unsigned int value)
{
unsigned int count = 0;
while (value > 0) {
if ((value & 1) == 1)
count++;
value >>= 1;
}
return count;
}
int main()
{
unsigned int n, count;
printf("Enter the number \n");
scanf("%d",&n);
count=check_power(n);
if(count == 1)
{
printf("number is power of 2\n");
}
else
{
printf("number is not power of 2\n");
}
printf("set bits == %d",count);
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
Differentiate abs() function from fabs() function.
What is p in text message?
code for find determinent of amatrix
What happens if a header file is included twice?
How can I open a file so that other programs can update it at the same time?
Describe newline escape sequence with a sample program?
`write a program to display the recomended action depends on a color of trafic light using nested if statments
What is a pointer in c?
What is the advantage of an array over individual variables?
int i=10; printf("%d %d %d", i, i=20, i);
What is the correct declaration of main?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
Is array name a pointer?