When your done your program should look something like this. make sure you understand what you are typing don't just mindlessly copy, you wont learn anything from that.
#include <iostream> using namespace std; int main() { cout << "Counting forward:\n"; for (int i = 0; i < 10; ++i) { cout << i << " "; } cout << "\n\nCounting backward:\n"; for (int i = 9; i >= 0; --i) { cout << i << " "; } cout << "\n\nCounting by fives:\n"; for (int i = 0; i <= 50; i += 5) { cout << i << " "; } cout << "\n\nCounting with null statements:\n"; int count = 0; for ( ; count < 10; ) { cout << count << " "; ++count; } cout << "\n\nCounting with nested for loops:\n"; const int ROWS = 5; const int COLUMNS = 3; for (int i = 0; i < ROWS; ++i) { for (int j = 0; j < COLUMNS; ++j) { cout << i << "," << j << " "; } cout << endl; } return 0; }
0 Comments
Leave a Reply. |
Jonathan N.Just a simple guy trying to help people understand programming along with me. We will be taking the journey of learning programming together. Archives
April 2016
Categories |