Hi, nice to meet you all. I'm having some trouble with my homework in my C++ coding class, and needed some help, even a push in the right direction would be appreciated!
My professor gave us this line of code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
//PLACE YOUR NAME HERE
#include <iostream>
usingnamespace std;
int main()
{
for(int i = 0; i < 2; i++)
for(int j = 0; j < 2; j++)
for(int k = 0; k < 2; k++)
cout << i << j << k << "\n";
return 0;
}
Then he posed this question:
Type the program above in and run it. This program counts from 000 to 111 in Binary (0 – 7 Decimal) using only digits 0 – 1. A related numbering system is Octal, and uses the digits 0 – 7. Modify the program above to count from 00 to 77 in Octal (0 – 63 Decimal).
Hint: You will only need 2 for loops instead of 3.
I'm a bit behind in my studying in this class, but this assignment will be due before I believe I can figure it out from the book. Can somebody help me understand what I need to type to make this code work?
Thank you!
//PLACE YOUR NAME HERE
#include <iostream>
usingnamespace std;
int main()
{
int i = 0;
while (i <= 10)
{
cout << i << "\n";
}
return 0;
}
When ran, it only displays repeated lines of 0's without end.
The instructions are:
"Type the above program and run it. Exit with Ctrl-C. What happens when you run it? How do you fix this program? Using an if statement and continue statement, only cout the even numbers."
Any suggestions on this one? I keep trying different ways to insert and if statement, but can't get a working result, especially with a continue.