/************************************************

* Character Diamond Creator *

* Version: 1.0 *

* Author: Musawir Ali *

* Bugs reported: none *

* About: program implemented using 'for' loop *

************************************************/

#include 

void main()

    {

     cout << "Character Diamond Creator v1.0";

     cout << "\nCreated by Musawir Ali.\n\n" << endl;

    

     char null=' '; //The empty character

     char c; //The character inputted by the user

     int line; //Number of lines

    

     /************** User Inputs *********/

     cout << "Enter a char: ";

     cin >> c;

     cout << "Enter the number of lines: ";

     cin >> line;

     /************************************/

     if(line%2 != 0) // Check if number of lines is odd

         {

         int sp=(line-1)/2; //Decides on the side spaces

         for(int n=0; n< (line/2); n++) //Top half of diamond

             {

             for(int j=0; j

             cout << null;

             for(int k=0; k<(line-2*sp); k++)

             cout << c;

             for(j=0; j

             cout << null;

             cout << "\n";

             sp--;

             }

             sp =0;

             for(n=0; n<= (line/2); n++) //Bottom half

                 {

                 for(int j=0; j

                 cout << null;

                 for(int k=0; k<(line-2*sp); k++)

                 cout << c;

                 for(j=0; j

                 cout << null;

                 cout << "\n";

                 sp++;

                 }

                 }

                 else //If number of lines is even

                     {

                     line--; //Take the odd number right before it

                     int sp=(line-1)/2;

                     for(int n=0; n<=(line/2); n++) //Top half

                         {

                         for(int j=0; j

                         cout << null;

                         for(int k=0; k<(line-2*sp); k++)

                         cout << c;

                         for(j=0; j

                         cout << null;

                         cout << "\n";

                         sp--;

                         }

                         sp =0;

                         for(n=0; n<= (line/2); n++) //Bottom half

                             {

                             for(int j=0; j

                             cout << null;

                             for(int k=0; k<(line-2*sp); k++)

                             cout << c;

                             for(j=0; j

                             cout << null;

                             cout << "\n";

                             sp++;

                             }

                             }

                             cout << "\nDemonstration of a character diamond complete using the for loop.\n";

                            

                             //End of Program

                        }