code help please! DU). Jave the solution UDINaIon. Close the Code Editor window
ID: 3875191 • Letter: C
Question
code help please!
DU). Jave the solution UDINaIon. Close the Code Editor window and then thht appinca close the solution. oTenAsterisks Solution (TwoToTenAsterisks Solution.sln) file contained in the ClearlyVB20121Chap151TwoToTenAsterisks Solution folder The Display Asterisks button should display the pattern of asterisks shown below The pattern contains 2 asterisks, 4 asterisks, 6 asterisks, 8 asterisks, and 10 asterisks. Display the pattern in the IblAsterisks control. Use a For...Next statement for the outer loop, and a Do...Loop statement for the nested loop. Save the solution and then start and test the application. Close the Code Editor window and then close the solution. Open the Table Solution (Table Solution.sln) file contained in the Clearly Chap151Table Solution folder. The Display Table button's Click event procedure should display a table consisting of three rows and seven columns, as shown in Figure 15-16 O.Explanation / Answer
The code will be as below. Please read the comments mentioned within /* */
{
int i, j, r; /* Interger i and j for Row & Column.As per the Diagram you can define r with number of rows */
/* Or else Go for User Input */
printf (" Enter the number of rows r : ");
scanf (" %d", &r); /* Asking for User to Input */
{
for (i= 1; i<=r;)
{
do
{
j= 1;
}
while (j<=i)
{
printf (" ** "); /* Here your Stars will get Printed */
j++;
}
printf ( " " ); /* For new Line for new Row */
i++;
}
getch();
}
}
Conclusions :-
**
****
******
********
**********
1. When i= 1 it will go inside the do while loop and assign the value j to 1. Then It will come out of the Do and check the condition in While which in turn help to print the star .
2. Once the value of j gets greater than i , it will go out of the bracket and move to next line as printf (" n ") is given, In that it will increment the value of i also.
3. Next when value of i= 2 , j=1 , Prints ** and increments the value of j and when goes back to the while loop condition it gets satisfied and again prints another two start like **** and increment the value of j.
4. This process continues till i gets incremented more that r and comes out of the loop.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.