Question

write a Nested loop in C# to print out the following output using windows form. 0...

write a Nested loop in C# to print out the following output using windows form.

0
0 1
0 2 4
0 3 6 9
0 4 8 16 32

Homework Answers

Answer #1

Code

public partial class Pattern : Form
{
public Pattern()
{
InitializeComponent();
}

private void Pattern_Load(object sender, EventArgs e)
{
for(int i=0;i<5;i++)
{
string str = "0 ";
int k = i;
for (int j = 1; j <= i; j++)
{
if (i % 2 != 0)
{
str += k + " ";
k += i;
}
else
{
str += k+" ";
k *= 2;
}
}
txtNestedloop.Text= txtNestedloop.Text +str +"\r\n";
}
}
}

design

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++ Code! Represent the following matrix using a two-dimensional array and write a nested for loop...
C++ Code! Represent the following matrix using a two-dimensional array and write a nested for loop to initialize the elements (do not initialize the array in the declaration): 10  9   8 7   6   5 4 3   2
     I'm trying to use a nested for-each loop to print out the names in the...
     I'm trying to use a nested for-each loop to print out the names in the two dimensional array but it's printing out "[Ljava.lang.String;@15db9742" instead and I don't understand why. is there another way to print out the both array using a nested for each loop?     public static void main(String[] args) {         String[][] str = {{"Steve", "Rick", "John"},{"Erick","Bob","Dave"}};                for(String[] s : str){             for(String e : s){             System.out.println(s);                       }         }       }...
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other my name's Aya amro
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other The first letter A and the last letter O
I'm trying to write a nested loop in Mips Assembly that prints out, for example, if...
I'm trying to write a nested loop in Mips Assembly that prints out, for example, if user input x was 5: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 (spaces in between) So far my code is : li $v0, 5   #Ask for integer syscall move $t5, $v0 addi $t0, $zero, 0 For1:    slt $t1, $t0, $t5    beq $t1, $zero, Exit    add $s0, $s0, $t0    addi $t0, $t0, 1...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider that your user might give you two of the same...
Write a nested FOR loop (using two for loops & two fprintf statements to generate the...
Write a nested FOR loop (using two for loops & two fprintf statements to generate the following pattern: ***** **** *** ** *
(SubtractionTable.java) Write a program that displays the following subtraction table. Notes: You must use a nested...
(SubtractionTable.java) Write a program that displays the following subtraction table. Notes: You must use a nested loop. There are spaces at the beginning of each row.                                                                                                                 2 - 1 = 1                                                                                                   3 - 1 = 2   3 - 2 = 1                                                                                   4 - 1 = 3   4 - 2 = 2   4 - 3 = 1                                                                   5 - 1 = 4   5 - 2 = 3   5 - 3 = 2   5 - 4 = 1  ...
Write a program on C++ to calculate and print the factorial of a number using a...
Write a program on C++ to calculate and print the factorial of a number using a for loop. The factorial of a number is the product of all integers up to and including that number, so the factorial of 4 is 4*3*2*1= 24.
Question: Write a C++ program to ask the user to give you the number of rows...
Question: Write a C++ program to ask the user to give you the number of rows and number of columns, then make the multiplication table by using nested loop. For example, if the user enters 3 for rows and 4 for columns then the multiplication table would be like the following: 1    2   3     4 1   1 2 3 4 2   2    4      6    8 3    3 6 9 12
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT