Going the Next Step

Hello!

I am taking Intro to Computer Science over the summer.

I was wondering if you could give me a question that would use the concept that was tested on my midterm. I solved the midterm problem, but I would like to go the next step. Thank you!

Question from midterm:
1) User enters integer n between 1 and 10; terminates if wrong value is entered.
2) Prints picture using * as a diagonal line that extends over n rows and has width of 3 characters in each row.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <cmath>
using namespace std;

//diagonal line with *** and n rows
int main ()
{
    int n;
    cout<<"Enter an integer between 1 and 10: ";
    cin>>n;

	if (n<=0 || n>10)
		cout << "Invalid entry";
	else {
		for (int r=0; r<n; r++){
			for (int c=0; c<r; c++){
                cout <<" ";}
        cout <<"* * *"<<endl;
    }
	}
   
    return 0;
}
Topic archived. No new replies allowed.