Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(int i=0; i<4; i++)
- {
- if(a[i]+b[i]+carry==3)
- {
- result[i]=1;
- carry=1;
- }
- if(a[i]+b[i]+carry==2)
- {
- result[i]=0;
- carry=1;
- }
- if(a[i]+b[i]+carry==1)
- {
- result[i]=1;
- carry=0;
- }
- if(a[i]+b[i]+carry==0)
- {
- result[i]=0;
- carry=0;
- }
- }
- result[4]=carry;
- for(int j=4; j>=0; j--)
- {
- cout<<result[j];
- }
- cout<<endl;
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement