Program to print the following pattern
Program in C:
#include <stdio.h>
int main()
{
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
printf("*");
for(int k=(10-2*i);k>=1;k--)
printf(" ");
for(int l=1;l<=i;l++)
printf("*");
printf("\n");
}
return 0;
}
Program in JAVA:
public class Pattern1
{
public static void main(String[] args)
{
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
System.out.print("*");
for(int k=(10-2*i);k>=1;k--)
System.out.print(" ");
for(int l=1;l<=i;l++)
System.out.print("*");
System.out.println();
}
}
}
No comments:
Post a Comment