answersLogoWhite

0

...

int i;

for( i = 0; i < 7; ++i ) {

printf("*");

}

printf("\n");

...

User Avatar

Wiki User

17y ago

What else can I help you with?

Continue Learning about Engineering

Do loop example?

A nested loop is simply a loop within a loop. An example of such a loop is where you wish to traverse a two-dimensional array. The simplest way to traverse such a structure is to use a loop to traverse each row and a nested loop to traverse the elements within each row. int a[4][5]; // a 4x5 array of integers (4 rows, 5 columns). // ... for (row=0; row&lt;4; ++row) // traverse rows { for (col=0; col&lt;5; ++col) // traverse columns { std::cout &lt;&lt; a[row][column] &lt;&lt; ", "; // print value at current row and column } std::cout &lt;&lt; endl; // keep each row on a separate line }


Algorithm to print diamond shaped star?

To print a diamond-shaped star pattern, you can follow these steps in an algorithm: Input the number of rows for the upper half of the diamond (let's call it n). For the upper half, iterate from 1 to n: Print n-i spaces followed by 2*i - 1 stars for each row i. For the lower half, iterate from n-1 to 1: Print n-i spaces followed by 2*i - 1 stars for each row i. This will create a symmetrical diamond shape using stars.


How do you generate the for loop in matrix?

To generate a for loop in a matrix, you typically iterate over the rows and columns of the matrix using nested loops. The outer loop iterates through each row, while the inner loop iterates through each column within that row. For example, in Python, you could use for i in range(rows): for the outer loop and for j in range(columns): for the inner loop. This allows you to access each element of the matrix using the indices matrix[i][j].


How do you program pyramid of letters using dev c plus programming?

#includeint main(){static int ROWS = 6;char ch;printf("Please enter an UPPERCASE letter:");scanf("%c",&ch);for( int row = 0; row < ROWS; ++row ){// Print padding.for( int column = 1; column < ROWS - row; ++column)printf(" ");// Print letters left of centre.for( int letter = row; letter >= 1; --letter)printf("%c", ch);// Print centre letter.printf("%c", ch);// print letters right of centre.for( int letter = row; letter >= 1; --letter)printf("%c", ch);printf("\n");}return( 0 );}


What mechanism would you implement in the process scheduler to automate the termination of a job that is in an infinite loop?

put a counter in. set it to zero before the loop. add 1 to it inside the loop pick a realistic number for how many times it could possibly go through legitamately and have it exit the loop if the counter goes above that. or if you do not have duplicate data each time through the loop save the data compare it the next time through and if it is the same 2 or 3 times in a row abort the loop.

Related Questions

Do loop example?

A nested loop is simply a loop within a loop. An example of such a loop is where you wish to traverse a two-dimensional array. The simplest way to traverse such a structure is to use a loop to traverse each row and a nested loop to traverse the elements within each row. int a[4][5]; // a 4x5 array of integers (4 rows, 5 columns). // ... for (row=0; row&lt;4; ++row) // traverse rows { for (col=0; col&lt;5; ++col) // traverse columns { std::cout &lt;&lt; a[row][column] &lt;&lt; ", "; // print value at current row and column } std::cout &lt;&lt; endl; // keep each row on a separate line }


Algorithm to print diamond shaped star?

To print a diamond-shaped star pattern, you can follow these steps in an algorithm: Input the number of rows for the upper half of the diamond (let's call it n). For the upper half, iterate from 1 to n: Print n-i spaces followed by 2*i - 1 stars for each row i. For the lower half, iterate from n-1 to 1: Print n-i spaces followed by 2*i - 1 stars for each row i. This will create a symmetrical diamond shape using stars.


How many rows with 6 stars are there on the American flag?

There are 50 stars in nine rows on the American flag. The number of stars per row are:First row: 6 starsSecond row: 5 starsThird row: 6 starsFourth row: 5 starsFifth row: 6 starsSixth row: 5 starsSeventh row: 6 starsEighth row: 5 starsNinth and last row: 6 starsThus, there are 5 rows of 6 stars and 4 rows of 5 stars.


How many rows with 5 stars are there on the American flag?

There are 50 stars in nine rows on the American flag. The number of stars per row are:First row: 6 starsSecond row: 5 starsThird row: 6 starsFourth row: 5 starsFifth row: 6 starsSixth row: 5 starsSeventh row: 6 starsEighth row: 5 starsNinth and last row: 6 starsThus, there are 5 rows of 6 stars and 4 rows of 5 stars.


How do you make the first row of a crochet?

The first row of a crochet project is usually a chain stitch row. Make a loop, insert the hook, engage the yarn, pull the engaged yarn through the loop and repeat.


What do stars in a row mean?

In a row means one after another on the same line. So "stars in a row" mean there are stars one after another all on the same line.


How do you write pascal tringle in php using while loop?

function pascal($depth){ $row = array(1); while($depth &gt; 0){ $newRow = array(1); for($n = 1; $n &lt; count($row); $n++){ $newRow[] = $row[$n - 1] + $row[$n]; } $newRow[] = 1; $depth --; echo implode(' ', $newRow) . "\n"; $row = $newRow; } }


How many stars on each row?

4 and 5 stars


C program for addition of two matrices?

I don't know the code, so I can't give it to you. But the algorithm is simple. Matrices are usually stored as 2 dimensional arrays. Say M and N. Then you make a loop, any loop, that goes through each row, during each loop, another loop will go over every single column (so row 1, col 1, then row 1, col 2, then etc.) Each time, the loop goes into row i and column j, add the entries of that row and column from M and N, (or M i,j + N i,j) and let it be the i,j's entry of the sum matrix. Do the code yourself.


How to make a grid using two for loops in python?

To create a grid using two for loops in Python, you can use nested loops where the outer loop iterates over rows and the inner loop iterates over columns. For example: rows = 5 cols = 5 grid = [] for i in range(rows): row = [] for j in range(cols): row.append((i, j)) # You can customize what each cell contains grid.append(row) print(grid) This code will generate a 5x5 grid where each cell contains its coordinates (row, column).


Write an algorithm for multiplication of two matrix using pointers?

To multiply two matrices using pointers in C, first ensure that the number of columns in the first matrix matches the number of rows in the second matrix. Then, allocate memory for the resultant matrix. Use nested loops: the outer loop iterates over the rows of the first matrix, the middle loop iterates over the columns of the second matrix, and the innermost loop calculates the dot product of the corresponding row and column, storing the result using pointer arithmetic. Finally, return or print the resultant matrix.


How many stars in each row on American flag?

There is five rows...so.......there is ten stars in each row. :)