A
BB
CCC
DDDD
EEEEE
does anyone have in idea of how to do code like that in C++??
email me:[email protected]
Yeah, but I am NOT a teacher. I don't care about how much someone actually 'learns'.You Idiot, you should be asking these questions on dedicated c++ forums, not these stupid sties, and to SMR, why on earth did you just give him the answer? now he wont need to solve the excercise for himself, this was a class assignment, dropping hints or pointers to the right direction is one thing, but straight out giving the code to someone like "manson52" wont help them learn shit
The only loop there is the for()
int main() is a function, not a loop, if that's what you're thinking. string() is not a loop, nor is cin.get(). A loop is for(), while() or do-while(). There is only one loop in your code.
And for the record that will probably print out FFFFFF too.
Change it to x<=5, not x<5.
#include<iostream>
#include<string>
using namespace std;
int main()
{
for(int x=0;x<=5;x++)
{
cout << string((x+1),65+x) << "\n";
}
cin.get();
return 0;
}
With mine:A
BB
CCC
DDDD
EEEEE
FFFFFF
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
char array[] = " ABCDE";
for(int i = 0; i < 7; i++)
{
for(int i2 = 0; i2 < i; i2++)
{
cout << array[i];
}
cout << "\n";
}
return 0;
}
I truly pity your programming/IT teacher. Tell your headmaster to offer him a pay rise for what he has to put up with.A
BB
CCC
DDDD
EEEEE