assume that the int variables i and j have been declared and that n has been declared and initialized to a positive value. using for loops (you may need more than one), write code that will display a triangle of asterisks of size n.



Answer :

In programming, an int (short for "integer") is a data type that represents a whole number value. Int variables are variables that are declared to hold integer values.

How to declare int variable ?

Int variables are typically used to store values that do not have decimal points, such as counts, sizes, or other quantities. They are typically stored in a computer's memory as binary values and can range in size depending on the specific implementation of the programming language.

int age = 30;

This code will use a nested for loop to display the asterisks in the desired triangle shape. The outer loop will iterate through each row of the triangle, and the inner loop will iterate through each column in each row.

The number of asterisks in each row will be equal to the row number, so the first row will have 1 asterisk, the second row will have 2 asterisks, and so on.

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

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

       System.out.print("*");

   }

   System.out.println();

}

To learn more about for loop refer :

https://brainly.com/question/19706610

#SPJ4

Other Questions