1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ryzh [129]
3 years ago
13

Write a C++ programthat reads in the side of a square and prints out a pattern on$

Computers and Technology
1 answer:
AnnZ [28]3 years ago
7 0

Answer:

#include<iostream>

using namespace std;

//main function

int main(){

   //initialize the variables

   int side;

   //print the message

   cout<<"Please enter the side of square: ";

   cin>>side;  //read the vale and store in the variable.

   // for loop

   for(int i=1;i<=side;i++){  //lop for rows

       for(int j=1;j<=side;j++){   //loop for column

           cout<<"$";  //print the '*'

       }

       cout<<endl;

   }

}

Explanation:

Create the main function and declare the variable side.

print the message on the screen for the user and then store value enter by the user on the variable side.

take the nested for loop for print the pattern.

nested for loop means, loop inside another loop it is used for print the pattern having rows and columns.

the first loop updates the row number and the second the loop print the character '$' in the column-wise.

in the code,

if i = 1, for loop check the condition 1 <= 5 if the value of side is assume 5.

condition is true and the program moves to the second for loop and starts to print the character '$' five times after that, print the new line.

then, the above process repeat for different rows and finally, we get the pattern in square shape.

You might be interested in
Please help ASAP!
makkiz [27]
B. training is the correct answer
8 0
2 years ago
Literacy is best defined as knowing how to: (Points : 1)
iragen [17]
Read and write. Think of the term "literacy rate" it refers to how much of a population can read and write.
5 0
3 years ago
Read 2 more answers
Anyone know a way to trade in a Xbox with a Ps4?
wlad13 [49]
I’m not sure sorry dude
5 0
3 years ago
Read 2 more answers
The U.S. continues to become more dependent on the global domain within the information environment consisting of the interdepen
cupoosta [38]

Answer:

cyberspace

Explanation:

It is the notional environment in which communication over computer networks occurs.

5 0
3 years ago
Select the correct text in the passage.
oksian1 [2.3K]

Answer:

Answer is given below

Explanation:

The index of the smallest value returned by function positionMin(),

and it is done by line "return minPosition;"

The input array is given as an argument in function selSort() and it is done by line "public static void selSort(int [] vals)" Here vals is input array argument.

6 0
3 years ago
Other questions:
  • In poor weather , you should ___ your following distance.
    12·1 answer
  • Holly Carpenter argues that technology may actually prevent some kinds of evolution that would benefit humans. Do you agree with
    8·2 answers
  • Which of these options would likely have a better playback experience in your presentation?
    8·2 answers
  • Which of the following instruments are used when performing a high-rate discharge test on a storage battery
    7·1 answer
  • Should the existing system be replaced?This is a question that is asked during the _____ stage of the Systems Development Life C
    8·1 answer
  • HELP PLZ !!
    13·1 answer
  • What's another word for contact print?
    15·2 answers
  • Why do many experts recommand longer time horizonal if you are doing high risk investment
    7·1 answer
  • What is the difference between the byte and short data types in Java?
    7·1 answer
  • For a certain company, the cost function for producing x items is C(x)=50x+100 and the revenue function for selling x items is R
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!