Like this "i" will be incremeted and the process continuous till i value become Make sure you try to draw it first and check it with my one. She could never understand the usual way which I tried in the beginning. One made my the spaces and another made by the stars. From this iteration onwarsd "else" part executes.
Thank you and visit www.
The first inner loop will print the spaces and the second one will print the stars. You can start coding. The number 34 denotes "j" value that prints last star Now j loop will be over and the control switch to next iteratio of "i" loop. Here first condition gets true, So compiler prints a star on the left hand side and increments the "kk" to 1.
Things to notice in this pattern: She asked me to help her out with the triangles and i drew this. The first question she asked what loop will we use?
For example in the first line, there is no star. There will be 2 outer for loops and there will be 3 nested for loops inside each outer for loop. After the program compiled and ran properly she was so. If you have any doubts please use the comments.
I am reinitializing the variable "kk" every time to zero on each iteration of outer "i" loop. I was trying to find a way how to start a conversation with her the next day.
You see there are 2 triangles in this pattern.
Now it may sound very confusing but lets see some pseudo code. In "else" part also we have two conditions connecting with "OR" operator.
Now star will be printed and kk value will be incremented to 6 Now this is what she told me- I could write this program by myself.
With a little help she wrote and it was correct. Finally there was this pattern which was our homework and she told me to help her out. Now what are these triangles? So that we can get the correct number of stars on the right hand side of the diamond.
Okay so try to do it yourself and check it with the code. And we need to approach it the same way we did the pattern number 2.
In this example we need to print on the 18th iteration of "i" loop like follows: Two inner loops to print a pattern: A more complex pattern program: Now star will be printed and kk value will be incremented to 8 In the second line there is 1 star.
I always liked patterns till that day when this girl asked me to teach her how to print patterns. So we divide the pattern into two halves- top and bottom. In the last row we will get all stars without space. Yes there are 6 triangles but out of them only 3 are needed at a time.C++ Program to Print Diamond of Stars.
In this Example we will learn how to Print Diamond of Stars in C++. So Lets see Example. Problem (Diamond Pattern Program In Java): Write a java program to print diamond of stars (*) or diamond of numbers like shown in the below image.
Write a C program to print hollow diamond star pattern series of n rows using for loop. Logic to print hollow diamond star pattern in C programming. Summary: in this tutorial, you will learn about C for loop statement to execute a block of code repeatedly.
Introduction to C for loop statement The C for loop statement is used to execute a block of code repeatedly. Write a C program to print hollow diamond star pattern of n rows using loops.
How to print empty diamond pattern in C programming language. C program to print hollow diamond star pattern.
C++ Program to Make a Simple Calculator to Add, Subtract, Multiply or Divide Using switch case To understand this example, you should have the knowledge of following C++ programming topics: C++ killarney10mile.com Statement.Download