Sum of two numbers without using arithmetic operators
Ex:int a=10;int b=10;int sum=a+b;without using "+" operator calculate sum
Answered by: jintojos
View all answers by jintojos
Member Since May-2008 | Answered On : Jul 17th, 2008
void main() { int a=10,b=20; while(b--) a++; printf("Sum is :%d",a); }
For two positive numbers: int main(){ int a = 10; int b = 10; printf("%d",a ^ b | ((a & b)<< 1)); return 0; }
Code#include<stdio.h> #include<conio.h> main() { int a=20,b=10,c; clrscr(); c=a-~b-1; //it will change the sign of operator truly magic printf("sum is %d",c); getch(); return 0; }
Engineering
Interview Coaching
Interview Questions
Tech FAQs
Describe a time when you had to listen to someone.
What is your way of building rapport with a person you just met?
Tell me about a skill you recently acquired or improved.
Do you find yourself busy most of the time? Why?
Importance of an MBA for an entrepreneur
Have you gone above and beyond your job description?
How productive are you?
Give me good reasons why should I choose you over others.
What will you do when you are not able to get your message across to your audience?
What do you think about continuous learning?
Ask Interview Question?
Have Career Question?
Ask Chandra
Ask Only Career questions.
Editorial / Best Answer
Answered by: jintojos
View all answers by jintojos
Member Since May-2008 | Answered On : Jul 17th, 2008
void main()
{
int a=10,b=20;
while(b--) a++;
printf("Sum is :%d",a);
}
For two positive numbers:
int main(){
int a = 10;
int b = 10;
printf("%d",a ^ b | ((a & b)<< 1));
return 0;
}