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
Stells [14]
3 years ago
15

Write a program that reads an integer and displays, using asterisks, a filled diamond of the given side length. For example, if

the side length is 4, the program should display[a diamond with the middle having 7 asterisks]
*

***

*****

*******

*****

***

*

Computers and Technology
2 answers:
vazorg [7]3 years ago
8 0

Answer:

side = int(input("Please input side length of diamond: "))

# for loop that loop from 0 to n - 1

for i in range(side-1):

   # inside the print statement we determine the number of space to print

   # using n - 1 and repeat the space

   # we also determine the number of asterisk to print on a line

   # using 2 * i + 1

   print((side-i) * ' ' + (2*i+1) * '*')

# for loop that loop from 0 to n - 1 in reversed way

for i in range(side-1, -1, -1):

   # this print statement display the lower half of the diamond

   # it uses the same computation as the first for loop

   print((side-i) * ' ' + (2*i+1) * '*')

Explanation:

The program is written in Python and well commented. The first for loop display the first half of the diamond while the second for loop display the lower half.

A screenshot of program output when the code is executed is attached.

zaharov [31]3 years ago
3 0

Answer:

  1. import java.util.Scanner;
  2. public class Main {
  3.    public static void main(String[] args) {
  4.        Scanner input = new Scanner(System.in);
  5.        int n = input.nextInt();
  6.        int l = 1;
  7.        for(int i=1; i <= n; i++){
  8.            for(int j=1; j<= l; j++){
  9.                System.out.print("*");
  10.            }
  11.            System.out.println();
  12.            l = l + 2;
  13.        }
  14.        l = l - 4;
  15.        for(int i=1; i < n; i++){
  16.            for(int j=1; j <= l; j++){
  17.                System.out.print("*");
  18.            }
  19.            System.out.println();
  20.            l = l-2;
  21.        }
  22.    }
  23. }

Explanation:

The solution code is written in Java.

Firstly use a Scanner object to accept an input integer (Line 5-6).

Create the first set of inner loops to print the upper part of the diamond shape (Line 8-14). The variable l is to set the limit number of asterisk to be printed in each row.

Next, create another inner loops to print the lower part of the diamond shape (Line 17-23). The same variable l is used to set the limit number of asterisk to be printed in each row.

You might be interested in
​___________, such as smart phones and social​ media, fundamentally change the nature of an industry and can be influential enou
svlad2 [7]

Answer:

Disruptive Technologies.

Explanation:

Smart Phones and the social media are very power tools they can be used to spread a news like a fire very rapidly.

People mostly believe the new that come on their smartphones and the social media.

So the employees of the company can also be influenced by these technologies hence they can disrupt the work of the company and can make or break the company.

6 0
4 years ago
How do i add an answer on brainly i click to add an answer and it sends me to the home page
cricket20 [7]

Answer:  try to just add as little as possible then add the answser or just reload your browser

Explanation:

7 0
3 years ago
When public relations professionals make provocative statements in newsgroups to get people to visit an organization's website o
goldfiish [28.3K]

Answer:

Pitching

Explanation:

According to my research on the different marketing stunts that organizations have done, I can say that based on the information provided within the question this type of Public Relations move is called Pitching. Like mentioned in the question they basically make a controversial statement in front of platforms with huge audiences in order to rile people up so they go visit their site or are aware of their project, which in term leads to sales.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

6 0
3 years ago
Computer programming(assembly language)​
Nikitich [7]

Konichiwa~. My name is Zalgo and I am here to be of assistance with your problem. The Computer Programming Assembly Language, which is sometimes referred as assembly or ASM is a low level programming language. Programs written in assembly languages are often compiled by an assembler. Every assembler has its own assembly language (meaning your assembly language could be the complete opposite of your friends/peers), which is designed for one specific computer architecture.

Hope this helps.

"Stay Brainly and stay proud!" - Zalgo

(By the way, do you mind marking me as Brainliest? I'd greatly appreciate it. Arigato~.)

6 0
4 years ago
you+increase+the+size+of+a+computer+screen+display+by+20%20%.+then+you+decrease+it+by+20%20%.+what+is+the+size+of+the+computer+s
emmainna [20.7K]

Answer:

The original size??? +20% and then -20% = 0%. If starting at 100% size the screen would be there.

6 0
2 years ago
Other questions:
  • Write a cout statement that prints the value of a conditional expression. The conditional expression should determine whether th
    7·1 answer
  • If a local DNS server cannot find an IP address for a specified URL, it does this.
    9·1 answer
  • Consider five wireless stations, A, B, C, D, and E.
    13·1 answer
  • Ted is asked to create a page of family photos for his family reunion Web site. He will have about 20 pictures to post, with a c
    5·1 answer
  • Anyone know the name of this font? and what site i can find it on so i can type it????
    8·1 answer
  • Both k-means and k-medoids algorithms can perform effective clustering. (a)Explain the strength and weakness of k-means in compa
    5·1 answer
  • Which of the following can computer maintenance software determine?
    6·1 answer
  • Failing to include a complete ____ on each side of an &amp;&amp; operator in an if statement is a common error in Java programmi
    6·2 answers
  • EEEEEEEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFFFFFGGGGGGGGGGGGGGGGGGGGGGGGGGGGGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHIIIIIIIIIIIIIIII
    9·2 answers
  • A regional bank implemented an automated solution to streamline their operations for receiving and processing checks/cheques. th
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!