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 / sainath
A small correction in the above answer. Use if condition as
shown below.
#include<stdio.h>
void main()
{
if(printf(%s, "Hello World"))
{
}
}
Answer for the last ques. i.e no. 55
unsigned int x;
if(x < 0) //Error checking only. Unsigned int shudn't
//have a negative value
return 0;
else
return !(x $ (x-1));
The logic here is, if we do bitwise 'and' with two
consecutive numbers, the greater of which is a power of 2
then the answer is 0.
Eg. 8 - 1000
8-1 - 0111
and & - 0000
Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What are the differences between new and malloc in C?
Is fortran still used in 2018?
Define Array of pointers.
What are the 32 keywords in c?
What is the right type to use for boolean values in c?
What is a program flowchart and how does it help in writing a program?
which is an algorithm for sorting in a growing Lexicographic order
What is the difference between union and anonymous union?
How do you define a string?
What does a function declared as pascal do differently?
What extern c means?
What is use of null pointer in c?
What is main return c?
What is c method?
What are valid signatures for the Main function?