Answer to Question #157186 in C++ for Angelie Suarez

Question #157186

What is the output of the code fragment below if

  1. X=5
  2. X=10
  3. X=3

(3 pts) void fun(int X) { if (X == 0) return; fun(X/2); cout<


1
Expert's answer
2021-01-24T11:10:10-0500
#include <iostream>
using namespace std;
void func (int x) {
    if (x == 0) return;
    func(x / 2);
    cout << x % 2;
}
int main () {
    func(5);
    cout << endl;
    func(10);
    cout << endl;
    func(3);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment