returning true or false value

I could not return true or false value instead of 1 and 0 with a function. Could someone help me with that please?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <iomanip>

using namespace std;

int isFactor(int, int);

int main(){
    cout << "Number 1" << setw(10)
     << "Number2" << setw(30)
     << "N. 1 is a factor of N. 2" << endl;
    
    int a{4};
    int b{8};
    cout << a << setw(12) << b <<setw(15)
      << isFactor(a, b) << endl;
    
    int c{7};
    int d{9};
    cout << c << setw(12) << d << setw(15)
    << isFactor(c, d) << endl;
    
    int e{5};
    int f{10};
    cout << e << setw(12) << f << setw(15)
     << isFactor(e, f) << endl;

     int g{1};
     int h{3};
     cout << g << setw(12) << h << setw(15)
     << isFactor(g, h) << endl;
     
     int i{8};
     int j{3};
     cout << i << setw(12) << j << setw(15)
     << isFactor(i, j) << endl;
}

int isFactor(int first, int second){
    if(second % first == 0){
        return true;
    }
    else{
        return false;
    }
}
bool isFactor(int, int);
(Both function and prototype).



You might want to add the line
cout << boolalpha;
before any output if you want to see true/false rather than 1/0
Thank you.
Topic archived. No new replies allowed.