ABCD Pyramid pattern

I was trying to do the abcd pyramid pattern under programming fundamentals 2.0. The code I made didnt end, ran infinitly and created a beeping sounf. Why?

#include
using namespace std;
int main()
{
int n;
cin>>n;
int i=0;
char ch=‘A’ ;
for(i=0;i<=n;i++)
{
for(int j=1;j<=n-i;j=j++)
{
cout<<ch;
ch=ch+1;
}
ch=ch-1;
for( int j=1;j<=n-i;j++)
{
cout<<ch;
ch=ch-1;
}
cout<<""<<endl;
}
return 0;

}

Hey Divyam, mention the problem’s exact name and copy your code on online ide save it and share that link here.

The code link is -
https://ide.codingblocks.com/s/52430
The question was abcd PYRAMID pattern in programming an fundamentals 2.0

Hey Divyam, there are some errors in your code

  1. declare char ch='A' ; insidefor(i=0;i<n;i++) loop
  2. update for(i=0;i<=n;i++) as for(i=0;i<n;i++)
  3. update for(int j=1;j<=n-i;j=j++) as for(int j=1;j<=n-i;j++)

I have corrected all these in your code you can refer this.

1 Like