0

Inline Code Example Herehi i want to print the diamond as shown bellow,which is generic i mean depend on the user input.the following output is for "5",

Heading Here

           1
          232
         34543 
        4567654 
       567898765 
        4567654
         34543
          232
           1

Edited by uzair.tabassumwahla: hi

2
Contributors
9
Replies
10
Views
4 Years
Discussion Span
Last Post by uzair.tabassumwahla
0
#include<iostream>
using namespace std;
int main()
{
    for(int i=0;i<13;i++)
    {
        cout<<"*";
        if(i==0 || i==12 ||i==9)
        {
            for(int j=0;j<10;j++)
            {
                if(i==9 && j==0)
                {
                    cout<<" ";
                }
                else
                    cout<<"*";
            }
        }
        else if(i==10)
        {
            cout<<" "; 
            cout<<"*";
            for(int j=0;j<7;j++)
            {
                cout<<" ";
            }
            cout<<"*";
        }
        else if((i==1 || i==2 || i==11))
        {
            for(int j=0;j<9;j++)
                cout<<" ";
            cout<<"*";
        }
        cout<<'\n';
    }
    return 0;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.