Question:
How we can add two numbers without using + symbol?
Answer:
use logicalor(|) operation to add the numbers Source: CoolInterview.com
Answered by: ameer | Date: 5/16/2010
| Contact ameer
A very simple example, only thing we need to define a macro instead of using the + symbol.
#include<stdio.h> #define add + main() { int a,b; a=5; b=a add a; printf("%d",b);
} Source: CoolInterview.com
Answered by: sree | Date: 5/24/2010
| Contact sree
#include<stdio.h>
main() { int a,b, res; scanf("%d",&a); scanf("%d",&b);
if(a == b) res = a*2; else res = (a*a - b*b ) / (a -b); printf("%d",res);
} Source: CoolInterview.com
Answered by: Ajay Singh Azad | Date: 6/15/2010
| Contact Ajay Singh Azad
#include<stdio.h> int addNumbers(int num1,int num2) { return (num1 - (~(num2-1))); }
main() { int num1,num2; int result;
result = addNumbers(num1,num2); printf("%d",result);
} Source: CoolInterview.com
Answered by: hillel | Date: 7/5/2010
| Contact hillel
main() { int num1,num2; int result; printf("enter nos"); scanf("%d%d",&num1,&num2); result=num1 - (~(num2-1)); printf("%d",result); getch(); } Source: CoolInterview.com
Answered by: shashank kumar | Date: 7/28/2010
| Contact shashank kumar
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|