+ 1
How to print the following code:
plz help i am a newbie. i want to print the following code in c++ and it should be centered: A AB ABC ABCD plz reply keeping in mind that im a newbie and the code should be simple using the for loop
10 Answers
+ 16
1) make a loop for number of rows [r=0 to r=n]
2) make a loop , [inside 1) ]for spaces in left [any n>(length+1)/2 to 0]
//decrease n after each iteration of 1) by 2
3) then make a loop for characters[inside 1) ] start from k=1 to k=0
//with every iteration of 1) , increase value of k by 2
4) then jump to next line
//thats a very basic way of making these patterns
//edit : can't write the code ... I'm very beginner
give it a try by your own first , and then either comment here or on my code ... will correct it if some error occurs
+ 14
//modified code of Ashraf for spaces
//still , U should not see them & give it a try by yourself ...
#include <iostream>
using namespace std;
int main() {
for(int i = 0; i < 6; i++)
{
for(int j = 2*(6-i); j >0 ; j-=2)
cout<<char(' ');
for(int j = 0; j < i; j++)
cout<<char('A' + j);
cout<<endl;
}
return 0;
}
+ 7
its pretty easy .. all you need to do is think what do you want to print and how many times you want it ..
+ 5
https://code.sololearn.com/cvir0AJ3aC84/?ref=app
just made it..
look like homework âș
+ 4
https://code.sololearn.com/cNgWP6Qjq0Hi/?ref=app
+ 4
just made it now..
+ 4
if you want capital just change 'a' to 'A'
0
can u write the code?
0
what if we change the alignment like
A
BA
CBA
DCBA
the order does not matter