answersLogoWhite

0


Best Answer

#include <stdio.h>

int main() {

int rows, star, spaces;

int number_of_stars = 6;

int number_of_rows = number_of_stars;

for (rows=1; rows <= number_of_rows; rows++) {

for (spaces=1; spaces <= number_of_stars; spaces++) {

printf(" ");

}

for (star=1; star <= rows; star++) {

printf("*");

printf(" ");

}

printf("\n");

number_of_stars = number_of_stars - 1;

}

return 0;

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you make a star triangle using nested loop in a c program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you exit in nested loop in java?

You may exit a nested loop in Java using a break with a label for the outer loop.


What is computing in science?

Nesting is the process of organizing information in layers. For an example, a loop in a program can contain another loop which can contain yet another loop. This is called nested loops.


In C which loop is embedded within another loop?

The nested loop.


What is nesting in computer science?

Nesting is the process of organizing information in layers. For an example, a loop in a program can contain another loop which can contain yet another loop. This is called nested loops.


What is a nested loop in java?

A nested loop is a (inner) loop that appears in the loop body of another (outer) loop. The inner or outer loop can be any type: while, do while, or for. For example, the inner loop can be a while loop while an outer loop can be a for loop.


How do you use nested for loop on the image in matlab?

Please ask clearly what you want to do with the image and explain why a nested for-loop is necessary.


What is the definition of 'nested' in C programming?

In C a structure within a structure is called nested. For example, you can embed a while loop in another while loop or for loop in a for loop or an if statement in another if statement.


For loop program turbo c making a right triangle?

yes


Write a program in Java which will print all nested loop between 1 to 500?

Sure! Here's a Java program that will print all the nested loops between 1 to 500: public class NestedLoopExample { public static void main(String[] args) { for (int i = 1; i &lt;= 500; i++) { for (int j = 1; j &lt;= 500; j++) { System.out.println(&quot;i=&quot; + i + &quot;, j=&quot; + j); } } } } This program uses two nested for loops to iterate from 1 to 500. It prints the value of i and j for each iteration of the loops.


Which loop is used when two things are done at the same time?

A loop inside a loop, which is known as a nested loop.


Write a program that input a positive integer and prints a triangle using for loop?

write a program that reads in the size of the side of square and then pints a hollow square of that size out of asterisks and blanks?


When loops are nested does one loop have to end before the other begins?

If one loop ends before the next begins then they are not nested at all -- they are completely independent. To be nested, one loop must contain the other loop in its entirety. That is, the inner, nested loop must start and end within the outer, containing loop. Nested loop example (in C++): for( int x = 0; x &lt; 10; ++x ) // outer loop { for( int y = 0; y &lt; 10; ++y ) // inner loop (nested loop) { printf( "%d x %d = %d\r\n", x, y, x*y ); } // end of inner loop } // end of outer loop