+ 2
To change the position of Asterix to left to right, right to left, up to down and down to up..How to do these?Plz help
https://code.sololearn.com/cYg5vkMpF1ml/?ref=app This prints: * ** *** **** ***** But the question is to print: * ** *** **** ***** ***** **** *** ** * ***** **** *** ** *
4 Réponses
+ 2
Ok,
In the first one, you have to print height-1 spaces,( which Julien Quentin said that it was blank ).
First height = 5;
Print 5-1 = 4 spaces.
Then decrement height by 1;
So height = 4;
So print 4-1 = 3 spaces;
Keep decreamenting height by 1 and print height-1 spaces until height=1
So in the last you have to print 1-1 = 0 spaces.
And in another loop, you have to print 1 *
Then 2*
Then 3*
Like this.
+ 2
In the first loop of the third question,it will be like this:
for(i = 1; i <= height; i++){}
Then you have to print i-1 spaces. Means:
First, i = 1;
Print 1-1 = 0 spaces;
Then i = 2;
So print 2-1 = 1 space;
Then i = 3;
So print 3 - 1 = 2 spaces.
And in another loop, use another variable, like n.
for(n = height; n >= 1; n--){}
This loop will be used for the *
Every time you print a space, print "height" number of stars and decreament it by 1 until height = 1;
So, in the last print 1*
+ 1
Can u do the code for me?
+ 1
Look in the whatsapp group chat. Almost the whole ans is given there