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.
#include <iostream>
#include <cmath>
usingnamespace 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;
}