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


Please Help Members By Posting Answers For Below Questions

What is c programing language?

857


What is union and structure in c?

899


Is c high or low level?

805


What is null pointer constant?

819


What is the use of parallelize in spark?

798


How many parameters should a function have?

899


In which header file is the null macro defined?

1140


What is difference between union All statement and Union?

900


#include { printf("Hello"); } how compile time affects when we add additional header file .

1689


How can I do peek and poke in c?

870


What is the easiest sorting method to use?

857


How many levels of pointers can you have?

960


please give me some tips for the placement in the TCS.

1874


What do you mean by a sequential access file?

847


Explain what is meant by high-order and low-order bytes?

863