Skip to content
Snippets Groups Projects
Commit 765f6f58 authored by drempe9's avatar drempe9
Browse files

Added all exercises for week 4

parent 575188f6
No related branches found
No related tags found
No related merge requests found
File deleted
#include<iostream>
using namespace std;
int main() {
int i, n;
int initialInput;
cout << "Please enter an integer to start at: ";
cin >> i;
// save i for later
initialInput = i;
cout << "Now an integer to end at: ";
cin >> n;
// while loop implementation
while (i <= n) {
// print out the current value of i
cout << i << endl;
// increment i
i++;
}
// reset i
i = initialInput;
// do-while implementation
do {
//print out current i
cout << i << endl;
//increment
i++;
} while (i <= n);
return 0;
}
#include<iostream>
using namespace std;
int main() {
int i, n;
cout << "Please enter an integer to start at: ";
cin >> i;
cout << "Now an integer to end at: ";
cin >> n;
for (int j = i; j <= n; j++) {
// output current value
cout << j << endl;
}
return 0;
}
#include<iostream>
using namespace std;
int main() {
int numRows = 8;
// for each row
for (int i = 1; i <= 8; i++) {
// for each column
for (int j = 1; j <= i; j++) {
//output 1 asterisk
cout << '*';
}
// end the line after all printed
cout << endl;
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment