Need help with particular program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Need help with particular program

Hi guys. I just started my journey with c++ and I would like to ask for help. I need to write a program that draws a square with a chosen ASCII char. The square should be scalable ( user should be able to enlarge and shrink it) and movable ( user should be able to move the square around the screen). Would anyone be so kind to help me with this :)?

1st Dec 2016, 3:58 PM
Mateusz Janik
Mateusz Janik - avatar
1 Answer
0
See, if it's the program you are asking for. #include <iostream> using namespace std; int main() { int _size, row, col; char sym; cout << "Enter size of the square: "; cin >> _size; while(_size<1 || _size>25) { cout << "Size must be an integer between 1 to 25, Enter again: "; cin >> _size; } cout << "\nEnter the Row from where to start the square: "; cin >> row; while( row<0 || (row+_size)>26 ) { cout << "\nRow must be in the range of 1 to " << 26-_size << " , Enter again: "; cin >> row; } cout << "\nEnter the Column from where to start the square: "; cin >> col; while( col<0 || (col+_size)>40 ) { cout << "\nColumn must be in the range of 1 to " << 40-_size << " , Enter again: "; cin >> col; } cout << "\nEnter the symbol you want to print the square with: "; cin >> sym; system("CLS"); for(int i=1; i<row; ++i) cout << endl; for(int i=0; i<_size; ++i) { for(int j=1; j<col; ++j) cout << " "; for(int j=0; j<_size; ++j) cout << sym << " "; cout << endl; } cout << endl; return 0; }
1st Dec 2016, 6:41 PM
Mohammed Maaz
Mohammed Maaz - avatar