Your program is fundamentally correct, but it could be written in a much better way, like cire's. But I suppose that might be confusing if you started only a week ago.
One thing you can remove are the parenthesis from the condition in the for statements. For this kind of condition you don't need them
Also, since you know beforehand that some loops will be executed only once, like
1 2 3 4 5 6
for(a=1;(a<2);++a) // will be executed only once
{
cout<<"\n";
for(b=1;(b<=3);++b)
cout<<"3";
}
You can remove them
You mark will depend on if the teacher just cares that the output is correct
One of the concepts in programming is to recognise patterns and sequences.
In the required output, the pattern is quite clear to see, even at a glance, though it may become clearer after a little more thought.
#include <iostream.h>
int main()
{
int a, b;
for(a=1;(a==1);++a)
cout<<"1\n";
for(b=1;(b<=2);++b)
cout<<"2";
for(a=1;(a<2);++a)
{
cout<<"\n";
for(b=1;(b<=3);++b)
cout<<"3";
}
for(a=1;(a<2);++a)
{
cout<<"\n";
for(b=1;(b<=4);++b)
cout<<"4";
}
system("pause");
return 0;
}
The fact that there is in the series of loops a value steadily increasing from 1 to 4 is a good hint that there could have been a solution which uses that fact.