+ 1

Please tell me something about it ?

(1) what actually i doing ? (2) what actually j doing ? (3) if j <= i then why it can't be j <= row while both are same ? (4) why one of i or j is < and another is <= . Give me logical reason please ? https://code.sololearn.com/cWeFzR7RS0Sq/?ref=app

28th Mar 2022, 6:14 PM
Abhay mishra
Abhay mishra - avatar
4 Answers
+ 5
Abhay mishra See your pattern on rows = 5 First row has 1 * Second row has 2 * Third row has 3 * Fifth row has 5 * So i is for rows And j is to print number of stars In your code there is little change. There should be i < r and j <= i * //When i = 0, j should be j <= 0; ** //When i = 1, j should be j <= 1; *** // When i = 2, j should be j <= 2; **** ***** //When i = 4; j should be j <= 4; If you write j <= row instead of j <= i then on every new line same amount of * will be print Means when row = 5 Then pattern would be like this: You can try ***** ***** ***** ***** ***** Each row will have 5 * But when you do j <= i then number of * will be print on the basis of i So when i = 0 then * When i = 1 then ** When i = 2 then *** When i = 3 then **** When i = 4 then *****
28th Mar 2022, 6:49 PM
A͢J
A͢J - avatar
+ 2
Where is your code? There might be many situations but in which situation you are asking?
28th Mar 2022, 6:24 PM
A͢J
A͢J - avatar
+ 1
Additionally your signature for: int starpattern(int r) is expecting an int returned to the call. You have no return value. For what you are trying to do in the function you will not need one. Simply change it to: void starpattern(int r) and you will not get the error any more.
28th Mar 2022, 10:23 PM
William Owens
William Owens - avatar
0
A͢J oh sorry sir i forgot to attach it .
28th Mar 2022, 6:26 PM
Abhay mishra
Abhay mishra - avatar