Advertisement
pushrbx

Demonstrate how to do a divide in C++.

Oct 19th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. /************************************************
  2. * demonstrate how to do a divide. *
  3. ************************************************/
  4. #include <iostream>
  5. /************************************************
  6. * div -- Do a divide *
  7. * *
  8. * Returns: Result of the divide. *
  9. * *
  10. * divisor is reset to 1. *
  11. ************************************************/
  12. static int div(
  13. int *divisor // Pointer to the divisor
  14. )
  15. {
  16. int result = 5; // Divid end
  17. result=result/*divisor; /* Do divide */;
  18. *divisor=1;
  19. return (result);
  20. }
  21. int main()
  22. {
  23. int num = 5; // Divisor
  24. std::cout << "Division " <<
  25. div(&num) << std::endl;
  26. return (0);
  27. }
  28. /***********************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement