Hello, I am a beginning student in a C programming class. I am having trouble understanding an assignment my instructor issued but has not lectured over it yet (it is due before she lectures over it).
The assignment is:
1) Write a program that asks the user for a a single character and two XY coordinates. The two X and two Y values should all be integers between 0 and 50. The character should be a printable ASCII character with values between and including ' !' (ascii value 33) and '~' (ascii value 126).
2) Your program should then draw a rectangle made up of the user selected character where the upper left corner is at X1; Y 1 and the lower right corner is at X2; Y2. Be sure to print the appropriate number of blank lines (having spaces in the blank rows is OK) in the beginning and pad each row of your rectangle with X1 leading spaces.
The Output is supposed to be similar to this:
(X1,Y1) = (0,0) , (X2,Y2) = (4,4), the character = ^
^^^^
^^^^
^^^^
^^^^
What I am having trouble understanding is printing between certain ASCII values (ASCII has never been discussed in class).
Another thing I am having trouble with is the main part of the assignment. From what we are currently discussing is loops and the assignment is covering nested loops. My code looks similar to this:
My thinking on the assignment is that you want the X1 coordinate to increase to the value of X2 (same for Y1 and Y2). Is this thinking wrong?Code:#include <stdio.h> int main (void) { int X1, Y1, X2, Y2; char cRec; printf("Enter a character: "); scanf("%c", &cRec); printf("\n"); printf("Enter point 1 (close to origin): "); scanf("%d,%d", &X1, &Y1); printf("\n"); printf("Enter point 2 (farthest from origin): "); scanf("%d,%d", &X2, &Y2); printf("\n"); for (X1=0; X1 <= X2; ++X1) { for (Y1=0; Y1 <= Y2; ++Y1) { printf("%c", cRec); } } return 0; }