C program to generate X pattern


 Sample Output:

You may also like...

  • Sayantan Sinharay

    #include
    #include
    using namespace std;

    int main()
    {
    int x=1;
    for(int i=-2;i<=2;i++)
    {
    for(int j=-2;j<=2;j++)
    {
    if(j==i || abs(j)==abs(i))
    cout<<x;
    else
    cout<<" ";
    }
    x++;
    cout<<endl;
    }
    return 0;
    }

    i hope this is much better sir

  • Aman Rustagi

    Thanks a lot for sharing this star pattern program. here is the set of c programs triangle, pyramid, geometrical shapes and star patterns