#include <iostream>
using namespace std;
int main()
{
    int a, b;
    char c, d;
    cin >> a >> b >> c >> d;

    for (int row = 1; row <= a; row++ ){
        cout << c;
        for (int cols = 1; cols <= b; cols++){
            cout << d;
        }
    }
    cout << c;
}
// this code outputs 
Sample Input 
10 4 | -
10 is the number of interval
4 is the width of an interval
/ is the major mark
* is the minor mark
Sample Output 
|----|----|----|----|----|----|----|----|----|----|

I want to add another loop that when you type 'n' as a major mark
the output would be:
Sample Input
3 2 n x
Sample Output
0xx1xx2xx3

'n' value are numbers from 0, 1, 2, 3... and so on.

Frankly this example code is a fine example of poor coding practices. The variables declared in lines 5 and 6 don't convey what they are going to be used for or what they mean. This is unmaintable code and should be marked down at least a full grade for this alone.

As to adding another variable, that would start with an addition to the declaration in line 5. Why isn't this done now?

As to the example output, one would rewrite the internal code around lines 9 to 15. I would be guessing if you were looking for someone to write this for you but here, you write your code for homework and assignments. If you get stuck on some specific point then you ask about that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.