0
Please help me...I am not getting the output...What can i do !!
2 Réponses
+ 6
This is the correct code:
#include<iostream>
using namespace std;
int main ()
{
int i,j,k,n, choice; char ch;
do
{
cout<<"Enter the number of rows " "\n";
cin>>n;
cout<<"Enter the characters whose pattern you want " "\n";
cin>>ch;
cout<<"1 - Pattern 1 \n 2 - Pattern 2 \n 3 - Pattern 3 \n 4 - Exit" "\n";
cout<<"Enter your choice "; cin >> choice;
switch(choice)
{
case 1: for(i=1; i<=n ; i++)
{
for(j=1; j<=i; j++)
cout << ch;
cout << endl;
}
break;
case 2: for(i=1; i<=n; i++)
{
for(j=1; j<=n-i; j++)
cout << " ";
for(k=1; k<=i; k++)
cout << ch;
cout << endl;
}
break;
case 3: for(i=1; i<=n; i++)
{
for(j=1; j<=n-i; j++)
cout << " ";
for(k=1; k<=2*i-1;k++)
cout << ch;
cout << endl;
}
break;
case 4: break;
}
}while (choice !=4);
return 0;
}