how to add numbers without using arithmetic operators.

Answers were Sorted based on User's Feedback



how to add numbers without using arithmetic operators...

Answer / sneha

#include <stdio.h>

int add(int a,int b)
{
if(!a)
return b;
else
return add((a&b)<<1,a^b);
}

void main()
{
int a=2, b=3, c;
c = add(a,b);
printf("%d\n",c);
}

Is This Answer Correct ?    15 Yes 3 No

how to add numbers without using arithmetic operators...

Answer / lookog

int add2(int a,int b)
{int s;
char *p=(unsigned)a;
s=&p[b];
return(s);
}

The previous soln with int would not be accurate, as int
storage is platform dependent. char is 1 bytes mostly.p[b]
is equivalent to *(p+b) and already p=a has been set.
though result is coming for -1000,-1000, not sure what it
means physically(address of -2000 ?)

Is This Answer Correct ?    1 Yes 0 No

how to add numbers without using arithmetic operators...

Answer / srikanth

int main()
{
int a=3,b=5;
printf("
%d
",printf("%*c%*c",a,' ' ,b,' '));
}

Is This Answer Correct ?    0 Yes 0 No

how to add numbers without using arithmetic operators...

Answer / karna

i am eager to see this progrm answer

Is This Answer Correct ?    0 Yes 1 No

how to add numbers without using arithmetic operators...

Answer / santhi perumal

#include<Stdio.h>
#include<conio.h>

void main()
{
int a=10,b=20;
while(b--) a++;
printf("Sum is :%d",a);
}

Is This Answer Correct ?    9 Yes 11 No

how to add numbers without using arithmetic operators...

Answer / abdur rab

#include <stdio.h>

int main ( int argc, char* argv [ ] )
{
int value1 = 10;
int value2 = 5;
printf ( "\n The sum is :%d", value1 | value2 );
}

Is This Answer Correct ?    10 Yes 12 No

how to add numbers without using arithmetic operators...

Answer / autojack

#include<stdio.h>
#include<conio.h>
void main()
{
int a=5,x=10,c;
clrscr();
c=a|x;
printf("%d",c);
getch();
}

Is This Answer Correct ?    2 Yes 5 No

how to add numbers without using arithmetic operators...

Answer / satish gaikwad

oh sorry I have considered as addition operator

Is This Answer Correct ?    2 Yes 6 No

how to add numbers without using arithmetic operators...

Answer / mokka samy

use the variable u can get it

Is This Answer Correct ?    2 Yes 6 No

how to add numbers without using arithmetic operators...

Answer / valli

#include<stdio.h>
main()
{
int a=5,b=6,s;
int *p=a;
s=&p[b];
printf("%d",s);
}

Is This Answer Correct ?    1 Yes 5 No

Post New Answer

More C Interview Questions

What does volatile do?

0 Answers  


pgm to reverse string using arrays i.e god is love becomes love is god) (assumption:only space is used for seperation of words) no addtional memory used.i.e no temporary arrays can used.

4 Answers   Persistent, Valyoo,


What standard functions are available to manipulate strings?

0 Answers  


why u join this call center?

6 Answers   DELL,


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} what would be the output?

1 Answers   Wipro,






What are shell structures used for?

0 Answers  


what is the defrenece between structure and union

5 Answers   Aloha Technology,


Is c is a high level language?

0 Answers  


Differentiate between static and dynamic modeling.

0 Answers   Wipro,


to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?

0 Answers  


Why c is known as a mother language?

0 Answers  


Define a structure to store the record of library. The record must consist of at least following fields: Title, Author, Edition, Price, Publisher, and Category. -Define functions authorSearch ( ), TitleSearch ( ) and CategorySearch ( ) to search a book with respect to author, title and category. [There can be more than one book, written by one author, in one category]

2 Answers  


Categories