Alright so one of the questions in my book asks....

"Consider the following program segment:

"Write a while loop equivalent to the for loop."Code:count = 0; for (i = 0; i < n; i++) { cin >> x; if (x & i == 0) count++; }

"Write a do-while loop equivalent to the for loop."

Now I'm not really sure how to re-write different types of loops. I'm having trouble figuring out where to put the requirements "(i = 0; i<n; i++)" and " (x & i == 0)

Here is what I attempted:

While loop.

do-while loop.Code:count = 0; int i=0; while(i < n) { cin>>x; if (x % i == 0) count ++; }

Please let me know if I am doing these all wrong!Code:count = 0; do { cin >> x; if (x % i == 0) count ++; }while (i < n);

Thanks!