- 4
Help
To write a program pattern 1 2 3 2 3 4 5 4 3 4 5 6 7 6 5 4 5 6 7 8 9 8 7 6 5
9 Réponses
+ 4
show your attempt
also, your assignment is now my property
+ 3
I see you have completed 7% of the C course, explore more to know about this
+ 2
Rahul Gupta
Hint:
1 - start a loop
for (int i = 0; i < 5; i++)
2 - make a variable inside this loop and assign value like..
int k = 2 * i + 1; because your each line of pattern is length of 1, 3, 5, 7, 9
3 - take another variable l and assign value of i to l like..
int l = i;
4 - now start another loop inside first loop and your new loop will like this:
for (int j = 0; j < k; j++)
5 - Now check condition inside new loop (mentioned in 4th step
if (j <= k / 2) //increase l by 1
else //decrease l by 1
and after this condition print l with space like this:
cout << l << " ";
6 - now add this line after new loop to print each line of pattern with new line
cout << endl;
+ 2
You are amazing thank so much
+ 2
Rahul Gupta
I don't have time to teach anyone but you have doubt then ask in QA.
Pattern understading comes from practice.
+ 1
Just go and google pattern programing . you will find thousands like that codes there
+ 1
Ok thank u for your help and advice☺️
0
Can you pls teach me
- 4
Pls😥😥