Rewrite the following piece of code using only if() and while() statements:


 case'a': p = one(q);
        break;
 case'b': p = p %2;
 case'c': do {
    r += p*q;
    p *=2;
   } while (p < 20);
      break;
 case 'd':
 case 'e': for(i=0;i<4;i++) {
    p += q+r;
    q = q/2;
    r = r%2;
   }
   break;
default: cout << "Try again!\n";
}

And you need it in C++(?) or in PHP? What have you done so far?

Member Avatar for diafol

That's C++ ? Anyway, we don't do "demands". Sounds like a piece of homework to me. If you can't be bothered to post to the right forum or even attach a simple 'please', I don't fancy your chances.

That's C++ ?

I think so, but I could be wrong, at first when I saw cout I though it was Python, but the switch method is different.

Member Avatar for diafol

I think so too. Heh.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.