Hiii again i have done dis program but i get o/p like dis
1
2
3
4
5
6
7
8....


I need to get like dis
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21

#include<iostream>
using namespace std;
int main()
{
    int j=0,m=1;
    for(int i=1;i<=6;i++)
    {
    for(j=1;j<=i;j++,m++)
    {
            cout<<m<<endl;
    }       
   
    }
    system("Pause");
    }

First, please use real English words (i.e. not "dis"). Second, I would keep track of the number in a separate counter that is incremented manually in the inner loop rather than trying to increment j and m in the loop definition. Give that a try and see if it helps.

Dave

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.