Created
January 10, 2014 09:41
-
-
Save Zulqurnain/797c03456187b8be3764 to your computer and use it in GitHub Desktop.
C++ code to add Two number without using any operator .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<iostream> | |
| using namespace std; | |
| /* | |
| Reason: when we are doing p[i] it is actually equall to *(p+i) , | |
| similarly when we are doing &p[i] it is equal to (p+i) so giving address, | |
| when we do &((&p[a])[b]) is it equall to (p+a+b) , p=0 so 0+a+b = a+b , | |
| i have used integer type casting because pointer p was of character type | |
| */ | |
| int main(){ // By Zulqurnain jutt | |
| int a=1,b=0; | |
| char *p=0; | |
| cout<<"a + b :=:"<<(int)(&((&p[a])[b]))<<"\n"; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment