As stated in the title, could somebody help me tidy up my program?
The question for this task was:
Using vectors create a program that converts randomly generated
integer numbers between 0 and 10 to binary and displays the converted numbers.
Currently my code is outputting the random integers and binary numbers... but they're all jumbled up and not spaced apart...the binary numbers are also being displayed backwards (you have to read them from right to left).
Could somebody help me sort these problems out?
Here is my program.
cout<<"Converting decimal to binary"<<endl<<endl;
srand(time(NULL)); // This is used for random seeding of random numbers.
int randomVectorSize = 1+ rand()%5; //This generates a random number between 1 and 6
vector<int> numbersToBeConverted;// This creates the vector where our randomly generated decimal numbers will be stored
for(int i= 0; i<randomVectorSize; i++) //This code generates a vector with a random size between 1 and 6
int randomNum = rand()%10; // This generates a random number between 0 and 10
numbersToBeConverted.push_back(randomNum); // This stores the random number generated in the vector
for(int j = 0; j < numbersToBeConverted.size(); j++)
cout<<endl<< numbersToBeConverted[j] <<" "<<endl;
binary = (randomNum%2);
randomNum /= 2;
for(int a = 0; a < bin.size(); a++)
cout<< bin[a] <<" ";