Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a, b;
- float ILORAZ(int a, int b){
- if(b==0){
- return -1;
- }
- else if(a<0 || b<0){
- return -2;
- }
- else{
- return a/b;
- }
- }
- int main()
- {
- cout << "Podaj pierwsza liczbe: " << endl;
- cin >> a;
- cout << "Podaj druga liczbe: " << endl;
- cin >> b;
- if(ILORAZ(a,b) == -1){
- cout << "Nie dziel przez 0" << endl;
- }
- else if(ILORAZ(a,b) == -2){
- cout << "Program działa tylko na liczbach dodatnich" << endl;
- }
- else{
- cout << ILORAZ(a,b) << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment