*
***
*****
*******
*********
Problem statement:- Program to print the Full Pyramid Star Pattern.
Data requirement:-
Input Data:- row_size
Output Data:- *
Additional Data:-out, start_print, in or inn(for python)
Here is the source code of the C Program to print the Full Pyramid Star Pattern.
Input/Output:
Code:
Input/Output:
***
*****
*******
*********
Problem statement:- Program to print the Full Pyramid Star Pattern.
Data requirement:-
Input Data:- row_size
Output Data:- *
Additional Data:-out, start_print, in or inn(for python)
Program in C
Here is the source code of the C Program to print the Full Pyramid Star Pattern.
Code:
#include<stdio.h>
int main()
{
printf("Enter the row size:");
int row_size;
scanf("%d",&row_size);
int star_print=1,in,out,p;
for(out=0;out<row_size;out++)
{
for(in=row_size-1;in>out;in--)
printf(" ");
for(p=0;p<star_print;p++)
printf("*");
star_print+=2;
printf("\n");
}
}
int main()
{
printf("Enter the row size:");
int row_size;
scanf("%d",&row_size);
int star_print=1,in,out,p;
for(out=0;out<row_size;out++)
{
for(in=row_size-1;in>out;in--)
printf(" ");
for(p=0;p<star_print;p++)
printf("*");
star_print+=2;
printf("\n");
}
}
Input/Output:
Enter the row size:5
*
***
*****
*******
*********
Program in C++
Here is the source code of the C++ Program to print the Full Pyramid Star Pattern.
*
***
*****
*******
*********
Program in C++
Here is the source code of the C++ Program to print the Full Pyramid Star Pattern.
Code:
#include<iostream>
using namespace std;
int main()
{
cout<<"Enter the row size:";
int row_size;
cin>>row_size;
int star_print=1,in,out,p;
for(out=0;out<row_size;out++)
{
for(in=row_size-1;in>out;in--)
cout<<" ";
for(p=0;p<star_print;p++)
cout<<"*";
star_print+=2;
cout<<"\n";
}
}
Input/Output:using namespace std;
int main()
{
cout<<"Enter the row size:";
int row_size;
cin>>row_size;
int star_print=1,in,out,p;
for(out=0;out<row_size;out++)
{
for(in=row_size-1;in>out;in--)
cout<<" ";
for(p=0;p<star_print;p++)
cout<<"*";
star_print+=2;
cout<<"\n";
}
}
Enter the row size:4
*
***
*****
*******
Program in Java
*
***
*****
*******
Program in Java
Here is the source code of the Java Program to print the Full Pyramid Star Pattern.
Code:
import java.util.Scanner;
public class StarPattern9 {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
System.out.println("Enter the row size:");
int row_size=cs.nextInt();
int star_print=1;
for(int out=0;out<row_size;out++)
{
for(int in=row_size-1;in>out;in--)
System.out.printf(" ");
for(int p=0;p<star_print;p++)
System.out.printf("*");
star_print+=2;
System.out.println();
}
cs.close();
}
}
Input/Output:public class StarPattern9 {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
System.out.println("Enter the row size:");
int row_size=cs.nextInt();
int star_print=1;
for(int out=0;out<row_size;out++)
{
for(int in=row_size-1;in>out;in--)
System.out.printf(" ");
for(int p=0;p<star_print;p++)
System.out.printf("*");
star_print+=2;
System.out.println();
}
cs.close();
}
}
Enter the row size:
6
*
***
*****
*******
*********
***********
6
*
***
*****
*******
*********
***********
Program in Python
Here is the source code of the Program to print the Full Pyramid Star Pattern.
Code:
row_size=int(input("Enter the row size:"))
star_print=1
for out in range(0,row_size):
for inn in range(row_size-1,out,-1):
print(" ",end="")
for p in range(0,star_print):
print("*",end="")
star_print+=2
print("\r")
star_print=1
for out in range(0,row_size):
for inn in range(row_size-1,out,-1):
print(" ",end="")
for p in range(0,star_print):
print("*",end="")
star_print+=2
print("\r")
Input/Output:
0 Comments
Please do not Enter any spam link in the comment box