Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <sys/types.h>
  3. using namespace std;
  4. ushort Divide(ushort a, ushort b);
  5.  
  6. int main(){
  7.   short a,b,c;
  8.   cout << "Please enter a number:";
  9.   cin >> a;
  10.   cout << "Please enter another number to divide by:";
  11.   cin >> b;
  12.   if (b < 0) {c = a/b;}
  13.   else if (a < 0) {c = a/b;}
  14.   else{
  15.     c = Divide(a,b);
  16.     if (c=-1){
  17.       cout << "No Number Can Be Divided by 0\n";
  18.       return 0;
  19.     }}
  20.   cout << a <<"/"<< b << "=" << c << "r" << endl;  
  21.   return 0;
  22.  
  23. }
  24.  
  25. ushort Divide(ushort a, ushort b){
  26.   if (b < 1){return -1;}
  27.   else{return a/b;}
  28. }
  29.  
  30. //Breakpoint 1, Divide (a=3, b=8) at ./main.cpp <------ it is being passed to Divide correctly, but will ALWAYS (unless using negatives
  31. //27      if (b < 1){return -1;}            (As they do not call Divide) return -1... any idea why?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement