Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. for(int i=0; i<4; i++)
  2. {
  3.  
  4. if(a[i]+b[i]+carry==3)
  5. {
  6. result[i]=1;
  7. carry=1;
  8. }
  9. if(a[i]+b[i]+carry==2)
  10. {
  11. result[i]=0;
  12. carry=1;
  13. }
  14. if(a[i]+b[i]+carry==1)
  15. {
  16. result[i]=1;
  17. carry=0;
  18. }
  19. if(a[i]+b[i]+carry==0)
  20. {
  21. result[i]=0;
  22. carry=0;
  23. }
  24.  
  25.  
  26. }
  27. result[4]=carry;
  28. for(int j=4; j>=0; j--)
  29. {
  30. cout<<result[j];
  31.  
  32. }
  33. cout<<endl;
  34.  
  35. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement