Ask Question

Assume that the int variables i and j have been declared, and that n has been declared and initialized. using for loops (you may need more than one), write code that will cause a triangle of asterisks of size n to be output to the screen.

+4
Answers (1)
  1. 7 June, 11:17
    0
    You should really state what language you're using. Here it is easily produced in C#, and shouldn't be too much of a hassle to translate to other languages. Note that I did not need to use the iterative variable (j), and could instead just use (i) in one for loop.

    Console. Write ("Enter size of triangle: ");

    int n = Convert. ToInt32 (Console. ReadLine ());

    for (int i = n - 1; i > = 0; i--)

    Console. WriteLine (new String ('*', n - i));
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Assume that the int variables i and j have been declared, and that n has been declared and initialized. using for loops (you may need more ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers