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
How is null defined in c?
Wt are the Buses in C Language
What is the difference between memcpy and memmove?
Can we declare function inside main?
please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................
Explain how can a program be made to print the line number where an error occurs?
What is New modifiers?
Write a program to show the change in position of a cursor using c
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
Explain modulus operator. What are the restrictions of a modulus operator?
When is a void pointer used?
Why #include is used in c language?
Why do we use namespace feature?
Why do we use int main?
What are reserved words?