[Solved] What’s wrong with this program in C++?


This should do the work.

#include <iostream>
using namespace std;
void chap(char,int,int);
int main()
{
int x,z,q;
char y;
cout<<"do you want run program?";
cin>>x;
while(x!=0)
{
    cout<<"enter your character: \n";
    cin>>y;
    cout<<"\nenter the number of lines: \n";
    cin>>z;
    cout<<"enter 1 for normal pattern and enter 0 for unnormal pattern : \n";
    cin>>q;
    chap(y,z,q);
    cout<<"do you want run program?";
    cin>>x;
  }
}

void chap(char y,int z,int q)
{
if(q==1)
    {
        for (int i=0;i<z;i++)
        {
            for(int j=0;j<=i;j++)
            {
                cout<<y;
            }
            cout<<"\n";
        }
    }
    if(q==0)
    {
        for(int i=z;i>0;i--)
        {
            for(int j=0;j<i;j++)
            {
                cout<< y;
            }
            cout<<"\n";
        }
    }
 }

solved What’s wrong with this program in C++?