Hello dear forum members,

I am brand new in C programming and have to program an "X" as homework (see attached picture).
The edge length of the "X's" should be entered by the user, ie the "X" should be arbitrarily large or small.

Can someone help me with the task?

So far I have the following code:

include <stdio.h>
     int main () {
     int edge length, i;
     printf ("Please enter the edge length of the pattern: \ n");
     scanf ("% d", & edge length);
     char sign;
     character = '';
     for (i = 0; i <edge length; i ++) {
     printf ("-% c- \ n", character);
     return 0;

Edited by Marcus_5

6 Months
Discussion Span
Last Post by Reverend Jim

Start with pseudo-code. If you were trying to tell someone how to draw the x, what would you say? If you can't figure out the general case (length=n) then start with a specific case (length=5) and write out one step for each row. Then try to generalize each row. That will give you the loop for length=5. From there you should be able to generalize for length=n.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.