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                      
tip   To Refer this Site to Your Friends   Click Here
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 ?    0 Yes 0 No
Vignesh1988i
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
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
main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%s\n",ptr); ptr++; printf("%s\n",ptr); } Find the Outputs? CitiGroup7
x=2,y=6,z=6 x=y==z; printf(%d",x) HCL8
Is there any restriction in how many arguments printf or scanf function can take? in which file in my c++ compiler i can see the code for implementation of these two functions??  3
what is the diff b/w static and non static variables in C. Give some examples plz. Wipro2
what is the associativity of bitwise OR operator?  1
which operator having highest precedence? a.)+ b.)++ c.)= d.)%  3
simple c program for 12345 convert 54321 with out using string  5
WRITE A PROGRAM TO FIND A REVERSE OF TWO NO  5
what is the output of the following program and explain the answer #include<stdio.h> exp() { main(5) } main(int a) { printf("%d",a); return; } Satyam3
what is the difference between structural,object based,object orientd programming languages? PanTerra1
How to swap two values using a single variable ? condition: Not to use Array and Pointer ?  4
write a own function for strstr LG-Soft1
Add 2 64 bit numbers on a 32 bit machine NetApp3
main() { int i,j,A; for(A=-1;A<=1;A++) prinf("%d\t",!!A); }  5
main() { char *p; p="Hello"; printf("%c\n",*&*p); } ME2
what is volatile in c language? TCS1
I have a function which accepts, and is supposed to initialize,a pointer, but the pointer in the caller remains unchanged.  1
Given a single Linked list with lakhs of nodes and length unknown how do you optimally delete the nth element from the list? Oracle1
what r callback function?  1
 
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