ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
Given an unsigned integer, find if the number is power of 2?
 Question Submitted By :: A. Sujatha
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Given an unsigned integer, find if the number is power of 2?
Answer
# 1
#include<stdio.h>
void powerOfTwo(int number)
{
 if(!(number & number-1) && number)
     printf("\nthe number is a power of 2\n");
 else printf("\nThe number is not a power of 2\n");
}
 

int main()
{
 powerOfTwo(32); //power of 2
 powerOfTwo(22);  //not a power of 2
 return 0;
}
 
Is This Answer Correct ?    1 Yes 1 No
Coder
 
  Re: Given an unsigned integer, find if the number is power of 2?
Answer
# 2
main()
{
        int i;
        printf("Enter Number :");
        scanf("%d",&i);
        if(i&(i-1))
                printf("Not atwo power");
        else
                printf("Two 's Power");
}
 
Is This Answer Correct ?    0 Yes 0 No
Veerendra Jonnalagadda
 
 
 
  Re: Given an unsigned integer, find if the number is power of 2?
Answer
# 3
main()
{
        int i;
        printf("Enter Number :");
        scanf("%d",&i);
        if(i&(i-1))
                printf("Not atwo power");
        else
                printf("Two 's Power");
}
 
Is This Answer Correct ?    0 Yes 0 No
Veerendra Jonnalagadda
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
write a C code To reverse a linked list Motorola2
What is memmove? Oracle1
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?  5
Write code for atoi(x) where x is hexadecimal string. Adobe2
To what value do nonglobal variables default? 1) auto 2) register 3) static  4
24.what is a void pointer? 25.why arithmetic operation can’t be performed on a void pointer? 26.differentiate between const char *a; char *const a; and char const *a; 27.compare array with pointer? 28.what is a NULL pointer? 29.what does ‘segmentation violation’ mean? 30.what does ‘Bus Error’ mean? 31.Define function pointers? 32.How do you initialize function pointers? Give an example? 33.where can function pointers be used?  1
Write a programme to find even numbers without using any conditional statement? Infosys3
main() {char a[10]={1,2,3,4,5,6};int x; for(x=0;x<4;x++){ b[x]=x+'a';} printf("%s",b);}  3
1,1,5,17,61,217,?,?.  3
Can we include one C program into another C program if yes how? Infosys4
what is the use of getch() function in C program.. difference b/w getch() and getche()?? Wipro12
regarding the scope of the varibles;identify the incorrect statement: a.automatic variables are automatically initialised to 0 b.static variables are are automatically initialised to 0 c.the address of a register variable is not accessiable d.static variables cannot be initialised with any expression TCS1
Write a program to print this triangle: * ** * **** * ****** * ******** * ********** Don't use printf statements;use two nested loops instead. you will have to use braces around the body of the outer loop if it contains multiple statements.  2
what is the return value (status code) of exit() function.... what the arguments(integer value) passed to it means.... TCS1
how to connect oracle in C/C++.  2
11. Look at the Code: #include<string.h> void main() { char s1[]="abcd"; char s2[10]; char s3[]="efgh"; int i; clrscr(); i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd")); printf("%d",i); } What will be the output? A)No output B) A Non Integer C)0 D) Garbage Accenture7
HOW TO HANDLE EXCEPTIONS IN C  5
In scanf h is used for BFL2
What should be keep precautions while using the recursion method?  1
what is c? Tech-Mahindra5
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com