Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sys/types.h>
- using namespace std;
- ushort Divide(ushort a, ushort b);
- int main(){
- short a,b,c;
- cout << "Please enter a number:";
- cin >> a;
- cout << "Please enter another number to divide by:";
- cin >> b;
- if (b < 0) {c = a/b;}
- else if (a < 0) {c = a/b;}
- else{
- c = Divide(a,b);
- if (c=-1){
- cout << "No Number Can Be Divided by 0\n";
- return 0;
- }}
- cout << a <<"/"<< b << "=" << c << "r" << endl;
- return 0;
- }
- ushort Divide(ushort a, ushort b){
- if (b < 1){return -1;}
- else{return a/b;}
- }
- //Breakpoint 1, Divide (a=3, b=8) at ./main.cpp <------ it is being passed to Divide correctly, but will ALWAYS (unless using negatives
- //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