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
c programming of binary addition of two binary numbers
 Question Submitted By :: Soham
I also faced this Question!!     Rank Answer Posted By  
 
  Re: c programming of binary addition of two binary numbers
Answer
# 1
the below program is for getting two numbers as input
(decimal format) and then the below program will convert in
binary and add WITHOUT ANY ARITHMETIC OPERATORS.....



#include<stdio.h>
#include<conio.h>
#define HIGH 1
#define LOW 0
void main()
{
long c[32],i,n,a,b,k,m,A,CARRY=0;
clrscr();
n=31;
printf("enter the value of a&b:");
scanf("%ld%ld",&a,&b);
for(i=0;i<32;i++)
{
  k=((a>>i)&1);
  m=((b>>i)&1);
   if(!(CARRY^HIGH))
   {
    c[n]=((CARRY^k)^m);
      if(!(k^HIGH)||!(m^HIGH))
       CARRY=1;
      else
       CARRY=0;
   }
   else if(!(k^HIGH) && !(m^HIGH))
   {
    CARRY=1;
    c[n]=k^m;
   }
   else if(!(k^LOW)||!(m^LOW))
   {
    if(!(CARRY^HIGH))
    {
     c[n]=((CARRY^k)^m);
     CARRY=0;
    }
    else
    c[n]=k^m;
   }
  n--;
}
for(i=0;i<32;i++)
printf("%d",c[i]);
getch();
}


thank u
 
Is This Answer Correct ?    2 Yes 0 No
Vignesh1988i
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
void main() { int i=5; printf("%d",i++ + ++i); } ME11
void main() { int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} }; int (*p)[2]; int i,j,*pint; for(i=0;i<=3;i++) { p=&s[i]; pint=p; printf("\n"); for(j=0;j<=1;j++) printf("%d",*(pint+j)); } } while running this program it shows a warning-suspicious pointer conversion ie pint=p; my que is why should we assign the value of p to pint again.why cant we use it directly as *(p+j)..but if i use like tat the o/p is garbage value..  1
Will Macros support multiple arguments ? Oracle7
write an algorithm and c program to add two 2x2 matrics  1
what are brk, sbrk? Oracle1
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
how to create c progarm without void main()?  1
write a program to copy a string without using a string?  1
Write an implementation of “float stringToFloat(char *str).” The code should be simple, and not require more than the basic operators (if, for, math operators, etc.). • Assumptions • Don’t worry about overflow or underflow • Stop at the 1st invalid character and return the number you have converted till then, if the 1st character is invalid return 0 • Don’t worry about exponential (e.g. 1e10), instead you should treat ‘e’ as an invalid character • Write it like real code, e.g. do error checking • Go though the string only once • Examples • “1.23” should return 1.23 • “1a” should return 1 • “a”should return 0 Qualcomm5
how to implement stack operation using singly linked list  1
What is key word in c language? ABC3
What is alloca() and why is its use discouraged?  1
how to find the size of the data type like int,float without using the sizeof operator?  8
What is the Difference between Class and Struct? Motorola9
How to add two numbers with using function?  3
what is the difference between declaration ,defenetion and initialization of a variable? LG-Soft5
How to calculate sum  2
how to do in place reversal of a linked list(singly or doubly)?  3
C program to find frequency of each character in a text file?  3
how to use showbits function? Infosys1
 
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