Full Pyramid

#include <stdio.h>

int main() {
	  int col,row,N;
    scanf("%d",&N);
    for(row=1;row<=N;row++)
    {
        for(col=1;col<=N-row;col++)
            printf(" ");
        for(col=1;col<=row;col++)
            printf("* ");
        printf("\n");
    }
	
	return 0;
}

Whats the problem ? my output and expected are same

nice problem, learnt something new

In general, building a pyramid by code is not very easy. But I made it by writing only three line codes😁. But I do not understand why my code is not acceptable. What is the problem in my code?.However why my stars are not showing up(one asterisk after print(" "* and one inside of )+“*”)

Python 3

n = int(input())
for i in range(n):
    print(" "*(n-(1+i))+"* "*(1+i))
   Scanner input=new Scanner(System.in);
        int N;
        N=input.nextInt();
        for (int r =1; r<=N; r++)
        {
            for (int c = 1; c <=N-r; c++){
                System.out.print(" ");
            }
            for (int c =1; c <=r; c++) {
                System.out.print(" *");
            }
                
            System.out.println();     
      } 

wthats the problem in my code ?

It seems that you have solved it yourself.

#include <stdio.h>
int main()
{
int n,row,col;
scanf(“%d”,&n);
for(row=1;row<=n;row++){
for(col=1;col<=n-row;col++)
printf(" “);
for(col=1;col<=row;col++)
printf(”* ");

        printf("\n");
}
return 0;

}

/What’s the problem in my code…anyone plz find the bug.Each time I run this it shows WA in the first case/

//what is the problem…please help me//

the program...
package hello;
import java.util.Scanner;

public class myp {

	public static void main(String[] args) {
		
	  //System.out.println("Write somthing:");
	  
		Scanner x =new Scanner(System.in);
		
         int a=x.nextInt(); 
		
			for(int i=0;i<a;i++) {
				for(int d=i;d<a-1;d++) {
					System.out.print(" ");
				}
				for(int j=0;j<=i;j++) {
 
				 System.out.print("* ");
			}
		
			 System.out.print("\n");
		}
			}
		

}

#Could anyone tell me the problem of my code:
N=int(input())
for i in range(N):
print(‘{}{}’.format(" “*(N-(i+1)),” "(i+1)))

What’s the problem of this code?!

n=int(input())
c=1
while(c<=n):
s=“”
for i in range(c):
if(i==0):
s+=“*”
else:
s+=" "
ss=s.center((2
n)-1)
#ss1=ss+“\n”
print(ss)
c+=1

#include

using namespace std;

int main()
{
int i,j,k,N;
cin>>N;
for(i=0;i<=N;i++){
for(j=i;j<N;j++){
cout<<" “;
}
for(k=0;k<i;k++){
cout<<” *";
}
cout<<endl;
}
return 0;
}

what is the problem

#include

using namespace std;

int main()
{
int i,j,k,N;
cin>>N;
for(i=0;i<=N;i++){
for(j=i;j<N;j++){
cout<<" “;
}
for(k=0;k<i;k++){
cout<<” *";
}
cout<<endl;
}
return 0;
}

What’s the problem in my code ???
#include<stdio.h>

int main()
{
int i,j,a,b,c,d,y,z,m;
char ara[100][200];
char x;
x = '';
for(i=0; i<100; i++) {
for(j=0; j<200; j++) {
ara[i][j] = ’ ';
}
}
scanf(“%d”,&a);
c = 0;
d = 0;
y = a;
z = (2
a) -1;
m = a-1;
for(i=0; i < y ; i++) {
b = i + 1;
d = m;
for(j=0; j < z; j++) {
if(j==m||j==d) {
if(c<b) {
ara[i][j]=x;
c++;
d = d +2;
}
}

    }
    m--;
    c=0;
}
for(i=0; i < y ; i++){
for(j=0; j < z; j++){
printf("%c",ara[i][j]);}
printf("\n");
}

return 0;

}

What’s wrong with my code ?

python3.8

number=int(input())
var=1
number_space=number
sign=“*”
val=0
while var<=number:
string=“”
if val==0:
for i in range(1,number_space):
string+=" "
string=string+sign
val=1
var+=1
number_space-=1
print(string)
else:
var+=1
for i in range(1,number_space):
string+=" "
for i in range(1,var):
if val!=number:
string+=(sign+" ")
else:
string=string+sign
number_space-=1
print(string)

Can anyone say what’s wrong with this code?
Preformatted text // C++ code to demonstrate star pattern
`#include
using namespace std;

// Function to demonstrate printing pattern
void triangle(int n)
{
// number of spaces
int k = 2 * n - 2;

// Outer loop to handle number of rows
// n in this case
for (int i = 0; i < n; i++) {

	// Inner loop to handle number spaces
	// values changing acc. to requirement
	for (int j = 0; j < k; j++)
		cout << " ";

	// Decrementing k after each loop
	k = k - 1;

	// Inner loop to handle number of columns
	// values changing acc. to outer loop
	for (int j = 0; j <= i; j++) {
		// Printing stars
		cout << "* ";
	}

	// Ending line after each row
	cout << endl;
}

}

// Driver Code
int main()
{
int n;
cin >> n;

// Function Call
triangle(n);
return 0;

}

I am unable to find my fault, it’s look everything ok in my IDE but wrong answer in here. help me out,
@hjr265

#Full Pyramid

n = int(input())

for i in range(n):
    print(" " * (n-i-1) + "* " * (i+1))

@abir123 Let’s say for the first line, you want to print 5 spaces and then an asterisk. Instead of printing something like xxxxx* (where the xs are spaces), you are printing xxxxx*x. Notice what’s wrong?

Yeah, bro. now understand… thanks again :slight_smile:

1 Like

I am totally stuck, @hjr265, please give me a suggestion…

#Full Pyramid

n = int(input())

for i in range(0, n + 1):
    for k in range(1, n +1 - i):
        print(" ", end="")
    for j in range(1, i + 1):
        print("*", end=" ")
    print()

What is wrong in my code?

#include <stdio.h>

int main() {
	int N,i,j,k;
	scanf("%d",&N);
	for(i=1;i<=N;i++)
	{
		for(k=1;k<=N-i;k++)	{
			printf(" ");
		}
		for(j=1;j<=i;j++){
			printf(" *");
		}
		printf("\n");
	}
	return 0;
}

** Where is the problem **

def makePyramid(x):
    pyramidSpace=' '
    pyramidSymble=' *'
    for i in range(x):
        y=i+1
        print(int(x-y)*pyramidSpace+y*pyramidSymble)

userInput = int(input())
if(0<userInput<100):
    makePyramid(userInput)

Screenshot 2022-06-12 at 10.05.18 PM