This program is basically working. I'm very knew to C++, so basically I need instructions as if you were explaining this to your grandma. I need this to loop and I have no idea how to incorporate one. Basic code (while loops). Here is what I've done so far. Please help!!
#include <iostream>
using namespace std;
int main () {
int i, c, k;
cout << "Please enter a number to convert: ";
cin >> i;
cout << endl;
cout << i;
cout << " in base 2 is ";
for (c = 10; c >= 0; c--) {
k = i >> c;
if (k & 1)
printf("1");
else
printf("0");
}
if (i == 0) {
cout << "0";
cout << endl;
cout << "Thanks for playing!";
cout << endl;
}
cout << endl;
return 0;
}
I need the program to have a while loop. It needs to keep asking for an integer until the user enters 0, then it can stop. I'm not trying to waste your time.
Thank you! I did finally figure it out to include the whole code it the while loop. I just have a hard time understanding what the while loops show say.