# Check severeal boolean returns in same time?

I have several bool elements and I am checking it if returns me false. bool i = false; switch (idcount) { case 1: i = p1(); break; case 2: i = p1() & p2(); break; case 3: i = p1() & p2() & p3(); break; case 4: i = p1() & p2() & p3() & p4(); break; case 5: i = p1() & p2() & p3() & p4() & p5(); break; case 6: i = p1() & p2() & p3() & p4() & p5() & p6(); break; case 7: i = p1() & p2() & p3() & p4() & p5() & p6() & p7(); break; } return i; I want if one of p*() returns false in any case i returns false. Is it right way or two false returns true? I want all p*() return true i returns true..

Patrick B.

tutor
All of the function * P take no arguments and returns boolean. So you can create the array and pointers to these functions and call them with a for loop instead of switch
Report

06/22/19

## 2 Answers By Expert Tutors

By:

Tutor
4.7 (31)

Math and computer tutor/teacher

Tutor
4.7 (31)

Math and computer tutor/teacher

## Still looking for help? Get the right answer, fast.

Get a free answer to a quick problem.
Most questions answered within 4 hours.

#### OR

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.