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?
Answers were Sorted based on User's Feedback
Answer / tyutyjtytydf
#include<stdio.h>
#include<conio.h>
main()
{
if(puts("hello world"))
{}
}
| Is This Answer Correct ? | 10 Yes | 0 No |
Answer / 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 |
Answer / ss
#include<stdio.h>
void main(){
if(printf("Hello World"))
{
}
}
| Is This Answer Correct ? | 6 Yes | 1 No |
Answer / amogh
53.
'num' is 32 bit integer
count=0;
for(;num!=0;count++)
num&=num-1;
55.
if(num&(num -1) == 0)
printf("%d is power of 2",num);
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / hussain reddy
/* mypro.c*/
#include<stdio.h>
void main()
{
remove("mypro.c");
}
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / lokesh n. jaliminche
/*program to check if number is power of 2
#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 |
Answer / 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 |
Answer / sankar kiran
#include<stdio.h>
#include<conio.h>
void main()
{
while(printf("Hello World"))
{
break;
}
getch();
}
| Is This Answer Correct ? | 6 Yes | 8 No |
Answer / swastisundar bose
52.
#include<stdio.h>
void main(){
if("Hello World")
{
}
}
| Is This Answer Correct ? | 17 Yes | 20 No |
What is the heap?
write a program that uses point of sale system. which are mainly used by retail markets, where the is a database inventory list, a slip should be printed for the customer. manage should be able to access what has been sold and what is left from stock?
Which of the following about the C comments is incorrect ? a.commentscan go over multiple lines b.comments can start any where in the line c.a line can contain comments with out any language statements d.comments can occur within comments
What is c standard library?
How many types of linked lists what are they? How many types of data structures?
18 Answers BSNL, Pivotal Software,
Which type of language is c?
3. When do you say that a digraph is acyclic A)if and only if its first search does not have back arcs B)a digraph is acyclic if and only if its first search does not have back vertices C)if and only if its first search does not have same dfnumber D)None of these
What does static mean in c?
what is the difference between NULL('\0') and 0?
9.how do you write a function that takes a variable number of arguments? What is the prototype of printf () function? 10.How do you access command-line arguments? 11.what does ‘#include<stdio.h>’ mean? 12.what is the difference between #include<> and #include”…”? 13.what are # pragma staments? 14.what is the most appropriate way to write a multi-statement macro?
Why is c so popular?
Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1