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
steposvetlana [31]
3 years ago
6

Consider the following code segment. for (int a = 0; a < 10; a++) { for (int b = 10; b > a; b--) { System.out.print("#");

} } How many "#" symbols are printed as a result of executing the code segment?
Computers and Technology
1 answer:
Ket [755]3 years ago
6 0

Answer:

55

Explanation:

Given the codes as below:

  1.        for (int a = 0; a < 10; a++)
  2.        {
  3.            for (int b = 10; b > a; b--)
  4.            {
  5.                System.out.print("#");
  6.            }
  7.        }

There are two layer loops in the code. The outer loop (Line 1) will run for 10 iterations by traversing through a = 0 to a=9. However, the inner loop  (Line 3) will run for 10 + 9 +  8 + 7 +...+ 1 = 55 iterations.

Since the print statement is within the inner loop (Line 5) and therefore the number of printed "#" symbols is dependent on the number of iterations of the inner loop. There will be 55 "#" symbols printed.

You might be interested in
A loop that will output only the names that come before "Thor" in the alphabet from the names list.
matrenka [14]

names = ["Kevin", "Joe", "Thor", "Adam", "Zoe"]

names.sort()

for x in names:

   if x == "Thor":

       break

   else:

       print(x)

I made up my own names for the sake of testing my code. I wrote my code in python 3.8. I hope this helps.

3 0
3 years ago
What would happen if computers only had input peripherals and a CPU?
lisov135 [29]
Then there would be no way to see the output based off what you input. =)
3 0
3 years ago
A variable like userNum can store a value like an integer. Extend the given program to print userNum values as indicated.(1) Out
dimulka [17.4K]

Answer:

The program in Java is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

 int userNum;

 Scanner input = new Scanner(System.in);

 System.out.print("Enter integer: ");

 userNum = input.nextInt();

 System.out.println("You entered "+userNum);

 System.out.println(userNum+" squared is "+(userNum*userNum));

 System.out.println(userNum+" cubed is "+(userNum*userNum*userNum));

 int userNum2;

 System.out.print("Enter another integer: ");

 userNum2 = input.nextInt();

 int sum= userNum + userNum2; int product = userNum2 * userNum;

 System.out.println(userNum+" + "+userNum2+" = "+sum);

 System.out.println(userNum+" * "+userNum2+" = "+product); } }

Explanation:

This declares userNum

 int userNum;

 Scanner input = new Scanner(System.in);

This prompts the user for input

 System.out.print("Enter integer: ");

This gets user input from the user

 userNum = input.nextInt();

Number (1) is implemented here

 System.out.println("You entered "+userNum);

Number (2) is implemented here

 System.out.println(userNum+" squared is "+(userNum*userNum));

 System.out.println(userNum+" cubed is "+(userNum*userNum*userNum));

This declares another variable userNum2

 int userNum2;

This prompts the user for another input

 System.out.print("Enter another integer: ");

This gets user input from the user

 userNum2 = input.nextInt();

This calculates the sum and the product

 int sum= userNum + userNum2; int product = userNum2 * userNum;

Number (3) is implemented here

 System.out.println(userNum+" + "+userNum2+" = "+sum);

 System.out.println(userNum+" * "+userNum2+" = "+product);

8 0
2 years ago
Which of the following restricts the ability for individuals to reveal information present in some part of the database?
Anni [7]

Answer:

it would have to be flow control which would be C.

Explanation:

8 0
3 years ago
The pc card and cardbus devices are being replaced by what technology?
Ronch [10]
They are replaced by ExpressCard

3 0
2 years ago
Other questions:
  • Help, please!! A file named "games.txt" exists and has 80 lines of data. You open the file with the following line of code. aFil
    6·1 answer
  • Which element in the PowerPoint application is not available in the Microsoft Word application?
    12·2 answers
  • 1. What is wrong with the following code?
    5·1 answer
  • Hardware refers to programs and protocols used on a computer system.<br><br> True<br> False
    8·2 answers
  • Which SCSI standard allows for the technique known as “hot swapping”? Ultra SCSI Original SCSI Serial SCSI Fast-Wide SCSI
    5·1 answer
  • Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. T
    6·1 answer
  • Which of the following statements best compares and contrasts hot and cold type?
    12·1 answer
  • Java question
    15·1 answer
  • You have been elected to assist the school's yearbook committee and newspaper club in purchasing new computers. The current comp
    10·1 answer
  • Since all Java data types (numbers, strings, etc) can be represented as strings, the _______ format specifier can receive any ty
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!