#include #include using namespace std; int main() { //Challenge #0: Count up to 10: 1 2 3 4 5 6 7 8 9 10 int i=1; while ( i <= 10 ) { cout << "current number: "; cout << i << endl; i = i + 1; } //for loop for (int i = 1; i <= 10; i = i + 1) //i=i+1 same as i++ { cout << "current number (with a forloop): "; cout << i << endl; } cout << endl; cout << endl; //Challenge #1: Count by 2's up to 20: 2 4 6 8 10 12 14 16 18 20 i = 2; while (i <= 20) { cout << i << endl; i = i + 2; } cout << endl; cout << endl; // Challenge #2: Ask for two numbers, first one smaller than 2nd : //example: 12, 17. Print: 12 13 14 15 16 17 int num1; int num2; cout << "Enter num1: "; cin >> num1; cout << "Enter num2: "; cin >> num2; i = num1; while (i <= num2) { cout << i << " "; i++; } cout << endl; for (int i = num1; i <= num2; i++) { cout << i << " "; } cout << endl; cout << endl; //Challenge #3: compute 1+2+3+...+100 int sum = 0; for (int i = 1; i <= 100; i++) { sum = sum + i; } cout << "The sum of integers from 1 to 100 is: " << sum << endl; cout << endl; cout << endl; //Challenge #4: Say the alphabet: a b c d e f .... char c; c = 'a'; //c has value 97 while (c <= 'z') { cout << c << endl; c = c + 1; } cout << "Next time won't you sing with me!" << endl; //Challenge #5: Alphabet again, but capitalize all the vowels c = 'a'; //c has value 97 while (c <= 'z') { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') { char capitalVersion; capitalVersion = c - 32; cout << capitalVersion << " (A Vowel!!!!)" << endl; } else { cout << c << endl; } c = c + 1; } cout << "Next time won't you sing with me!" << endl; cout << endl; cout << endl; //Challenge #6: Ask for user's name in lower-case. Print it back, but 1) vertically and 2) upper-case string name; cout << "Enter your name in lower case: "; cin >> name; for (int i = 0; i < name.length(); i++) { char capital = name[i] - 32; cout << capital << endl; } cout << endl; cout << endl; //Challenge #7: Ask user how many carry-on items they will bring on the plane. //Then, ask the weight of each item. Finally, tell user what the total weight is. cout << endl; cout << endl; //Challenge #8: Ask user to enter a number of rows and and line length, and print a box of those dimensions. //Example: If the user enters 3 for rows, and 5 for columns, the program displays a 3x5 box: // ***** // ***** // ***** int numRows; int numColumns; cout << "Enter number of rows: "; cin >> numRows; cout << "Enter number of columns: "; cin >> numColumns; for (int i = 0; i < numRows; i++) { //print 1 row of length numColumns for (int i = 0; i < numColumns; i++) { cout << "*"; } cout << endl; } //Challenge #9: Ask user to enter a number. Tell them how many distinct factors number has. return 0; }