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

1 1 2 1 2 3 1 2 3 4 1 2 3 1 2 1 generate this output using for loop

2 Answers  


main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none

0 Answers  


How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

0 Answers  


What is the difference between the local variable and global variable in c?

0 Answers  


A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none

0 Answers  






what is the use of pointers

6 Answers   Adobe, GrapeCity,


Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms

5 Answers   Convex Digital,


What is use of integral promotions in c?

0 Answers  


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

0 Answers   Wipro,


what are threads ? why they are called light weight processes ? what is the relation between process and threads ?

1 Answers  


int *p=20; if u print like dis printf("%d",p); o\p:- 20; how is it possible? plz give me the explanation.

15 Answers   Global Edge,


An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above

0 Answers  


Categories