4. Write a program that asks the user for a positive integer no greater than 15. The program should then display a square on the screen using the character 'X'. The number entered by the user will be the length of each side of the square. For example, if the user enters 5, the program should display the following: XXXXX XXXXX XXXXX XXXXX XXXXX
c++
It seems to be a problem with category pattern printing. Here you would like to print the pattern of SQUARE with the help of 'X' alphabet.
For simplicity purposes, I have divided the solution into parts.
Let's start :)
PART ONE: UNDERSTANDING THE REQUIREMENT
We need to write a C++ program that takes input less than 15 and print a square on the screen using the character X.
This is a problem of pattern printing. I will be giving you the step by step approach to solve this problem.
PART TWO: APPROACH
The basic idea will be counting how many characters we need to print.
On analysis, it is found that
when input = 4,
Output = 
This means 16 characters
and when input = 5
output = 
This means 25 characters,
Now we have got a formula, that the output is always the square of input number.
Now we can think of implementing this as a 2-D Matrix problem or nested loop problem.
PART THREE: IMPLEMENTATION
1. Before jumping to the coding part, please adhere to the following points.
2. Please read code comments at all the important sections of the program.
3. Please try to understand the solution by visualizing as 2-D matrix problem or nesting loops problem
*******************CODE*************************
#include <iostream>
using namespace std;
int main() {
cout<<"Please provide the size of
square?"<<endl;
//user input
int input;
while(1){
cin>>input;
if (input > 15)
{cout<<"INVALID INPUT: VALID
INPUT IS LESS THAN 15"<<endl;
continue;
}
else
break;
}
for(int i=0;i<input;i++)
{
for(int j=0;j<input;j++)
{
//Print X input
number of times
cout<<"X";
}
//Print other iteration in new
line
cout<<endl;
}
return 0;
}
**************************CODE*****************************
PART FOUR: SAMPLE INPUT AND OUTPUTS
INPUT VALIDATION:

This part checks whether the input is less than 15. if not, user is again prompted for input.
PATTERN PRINTING:

INPUT: 5
OUTPUT:

INPUT = 20
OUTPUT:

PART FIVE: MY PERSONAL RECOMMENDATION
As the problem statement wants to print a square pattern, try to print the characters with a space character. Please see the below-updated snaps
INPUT: 5
OUTPUT:

This figure looks like a better square. :)
Anyways it was really cool to discuss this much detail about this pattern.
I hope it helps and Please don't forget to thumbs up if it helped you.
Keep Learning Keep Chegging :)
Happy Coding
********************COMPLETE**********************
4. Write a program that asks the user for a positive integer no greater than 15....
C++ Write a program that asks user for a positive integer side length. If they enter an illegal value, they must be prompted to enter a good one until they do. It then displays, using asterisks, a filled diamond of the given side length. For example, if the side length is 4, the program should display:
Write a C++ program that asks the user for a positive number greater than 1 (does not have to be an integer). Call the sqrt function to return the square root of the number. Do this by including the cmath library. This page gives an example of using this sqrt function and including the cmath library.
Write a java program that asks the user to enter an integer. The program should then print all squares less than the number entered by the user. For example, if the user enters 120, the program should display 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.
C++ coding answer
5. Write a program that asks the user for a positive integer value. The program should use a loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2, 3, 4, ... 50. Input Validation: Do not accept a negative starting number.
In Python, write a program that asks the user for a positive integer number. If the user enters anything else, the program would ask the user to re-enter a number or enter -1 to quit. If it is a positive number, the program then prints out a multiplication table that goes up to that number. For example, if the user enters 10, the output would look something like this. https://www.vectorstock.com/royalty-free-vector/multiplication-table-on-white-background-vector-2721686
Using loops, write a C# program that asks the user to enter repeatedly an integer number, it stops when the user enters -1, then the program should display how many numbers were entered, their the sum and their average
Write a program in JAVA that asks the user to enter an integer. Store the integers in an array. Allow for up to 10 integers. When the user enters -1, the program should end. Print the number of integers entered as well as the number of times each integer was entered.
1. (sumFrom1.cpp) Write a program that will ask the user for a positive integer value. The program should use the for loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2, 3, 4, ... 50. If the user enters a zero or negative number, a message should be given and the program should not continue (see Sample Run...
Starting Out with C++ (9th Edition) Chapter 4, Problem 7PCWrite a program that asks the user to enter a number of seconds.• There are 86400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86400, the program should display the number of days in that many seconds.• There are 3600 seconds in an hour. If the number of seconds entered by the user is less than 86400, but is greater...
Write a Java program that reads in a positive integer from the user and outputs the following triangle shape composed of asterisk characters. For example, if user enters 5 as the input, then your program should display the following shape: ***** **** *** ** *