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
Irina-Kira [14]
3 years ago
8

Assume that the int variables i and j have been declared, and that n has been declared and initialized.

Computers and Technology
1 answer:
timama [110]3 years ago
8 0

Answer:

public class num6 {

   public static void main(String[] args) {

       int n = 4;

       for(int i = 1; i <= n; ++i) {

           for(int j = 1; j <= i; ++j) {

               System.out.print("* ");

           }

           System.out.println();

       }

   }

}

Explanation:

This solution is implemented in Java

Two for loops are required for this (an inner nd outer for loop).

The innner and outer for loops can be seen as implementing rows and columns (so on the first 'row' i=1, so a single star is printed, on the second row, i =2, two stars are printed and so on, all on seperate lines)

You might be interested in
PLS ANSWER ASAP!!!! <br><br> In three to five sentences, explain the function of utilities.
il63 [147K]

Answer:

In economics, utility function is an important concept that measures preferences over a set of goods and services. Utility represents the satisfaction that consumers receive for choosing and consuming a product or service.  Utility function is widely used in the rational choice theory to analyze human behavior.

Explanation:

7 0
3 years ago
Which of the following is NOT a reason we use subprograms?
NARA [144]

Answer: A. to add comments to Lines of code

Explanation:

8 0
2 years ago
Write a program which populates an array with integer values read from a file. We do not know how many integers are in the file,
max2010maxim [7]

Answer:

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

int main()

{

int arr[100];

int i = 0;

int j = 0;

char c[10];

char temp;

int sum = 0;

FILE* fp;

if ((fp = fopen("test.txt", "r")) == NULL) {

printf("cannot open the file");

return;

}

else {

do {

temp = fgetc(fp);

if (temp == ' ' || temp == '\n') {

c[j] = '\0';

arr[i++] = atoi(c);

j = 0;

continue;

}

c[j++] = temp;

} while (temp != EOF);

for (j = i - 1; j >= 0; j--) {

printf("%d\n", arr[j]);

}

}

getchar();

}

Explanation:

5 0
3 years ago
The length of a hailstone sequence is the number of terms it contains. For example, the hailstone sequence in example 1 (5, 16,
11111nata11111 [884]

Answer:

Following are the program to this question:

#include <iostream> //defining header file

using namespace std;

int hailstoneLength(int n) //defining method hailstoneLength

{

int t=1; //defining integer variable assign  

while(n!=1) //define a loop that checks value is not equal to 1

{

if(n%2==0) // check even number condition

{

n=n/2; // divide the value by 2 and store its remainder value in n

t++; //increment value of t by 1.

}

else

{

n=n*3+1; //calculate and hold value in n  

t++; //increment value of t variable by 1  

}

}

return t; //return value

}

int main() //defining main method

{

int n; //defining integer variable

cout<<"Enter any number: "; //print message

cin>> n; //input value

cout<<hailstoneLength(n); //call method and print its value

return 0;

}

Output:

Enter any number: 3

8

Explanation:

Program description can be given as follows:

  • In the given C++ language program an integer method "hailstoneLength", is declared, that accepts an integer variable "n" in its parameter.
  • Inside the method, an integer variable t is declared, that assign a value that is 1, in the next line, a while loop is declared, that uses if block to check even condition if number is even it divide by 2 and increment t variable value by 1.
  • If the number is odd it will multiply the value by 3 and add 1 and increment t by 1 then it will go to if block to check value again. when value of n is not equal to 1 it will return t variable value.
  • In the main method, an integer variable "n" is used that call the method and print its return value.
7 0
3 years ago
Anicius boethius invented a system that made possible the memorization and written transmission of melodies.
AURORKA [14]
The answer is false :)

7 0
3 years ago
Other questions:
  • Where do scanned documents go in windows 10?
    11·1 answer
  • How long does it take a letter to arrive?
    9·1 answer
  • How designers have created products from waste materials?
    7·1 answer
  • Moderate changes to existing processes falls under the _________ analysis. Business Process Automation (BPA) Business Process Im
    5·1 answer
  • Can your digital footprint be destroyed or does it remain active on the internet forever
    5·1 answer
  • Write a program that asks the user to enter the size of a triangle (an integer from 1 to 50). Display the triangle by writing li
    14·1 answer
  • Which technology will a business use to figure out who accessed confidential files on a company's computer system
    12·1 answer
  • JUST MAXED OUT THE COMMENTS anyways come here
    7·2 answers
  • Function of pons for class 7​
    15·1 answer
  • The memory used by the CPU to temporarily hold data while processing is called _______. random access memory central processing
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!