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


Please Help Members By Posting Answers For Below Questions

What are the differences between new and malloc in C?

604


Is fortran still used in 2018?

588


Define Array of pointers.

629


What are the 32 keywords in c?

627


What is the right type to use for boolean values in c?

580






What is a program flowchart and how does it help in writing a program?

655


which is an algorithm for sorting in a growing Lexicographic order

1394


What is the difference between union and anonymous union?

831


How do you define a string?

649


What does a function declared as pascal do differently?

603


What extern c means?

529


What is use of null pointer in c?

563


What is main return c?

513


What is c method?

531


What are valid signatures for the Main function?

697