/* Bit wise operator use less space in the memory */
#include<stdio.h>
#include<conio.h>
int add(int,int);
void main()
{
int m,n,sum;
clrscr();
printf("Enter the values of a and b:");
scanf("%d %d",&m,&n);
sum=add(m,n);
printf("The sum of the numbers: %d",sum);
getch();
}
int add(int m,int n)
{
int a,k;
do
{
a=m^n;
k=m&n;
m=a;
n=k<<1;
}while(k!=0);
return(a);
}
No comments:
Post a Comment