Hii,,
I need to make a program that takes in a user’s number and keep dividing it by 2 until it is 1.I need to display the division steps
i'm kinda new to c++ and i do not know how to keep making it divide by 2 until 1
i tired this but it obviously did not work..
some help? :x
code:
//Assignment 21 Program 4
#include <iostream>
using namespace std;
int main() {
//User Input
int input,total;
cout <<"Enter A Number To Be Divided By 2 Until 1" << endl << endl;
cout <<"Number: ";
cin >> input;
cout << "" <<endl;
do
{
total=input/2;
cout <<input<<"/2= ";
cout <<total<<endl;
break;
} while (!input==1);
system ("pause");
return 0;
}