Problem:  Write a c program to print Pyramid Patterns.
 
        *
        * * *
        * * * * *
        * * * * * * *
         * * * * * * * * *
Source Code:
  1.  /*
  2. * C Program to print full pyramid pattern using *
  3. */
  4. #include<stdio.h>
  5. #include<conio.h>
  6. int main()
  7.  {
  8.     int row, space, rows, star=0;
  9.     printf("Enter the number of rows in pyramid\n");
  10.     scanf("%d",&rows);
  11.  
  12.     for(row = 1;row <= rows; row++)
  13. {
  14.      /* Printing spaces */
  15.         for(space = 1; space <= rows-row; space++) 
  16. {
  17.            printf("  ");
  18.         }
  19.         /* Printing stars */
  20.         while(star != (2*row - 1)) 
  21. {
  22.             printf("* ");
  23.             star++;;
  24.         }
  25.         star=0;
  26.         printf("\n");
  27.     }
  28.     getch();
  29.     return 0;
  30. }
Outputs:
         

Related Posts:

  • Java Math Class -PyapirasThis is basic syntax of math class. Various type of example using Math class. Source Code:public class MathDemo { public static void main(String[] args) { // TODO Auto-generated method stub int a = 10,max; int b = 20;… Read More
  • Palindrome Number in Java - PyapirasThis is a palindrome number in Java program.1. Do you know  what is palindrome number?ans.   Palindrome number is a number which is same after reverse.as a example : 121 reverse it the result will be 121.Palind… Read More
  • Leap Year calculate in Java - PyapirasThis is a java program to check a year is leap year or not.lea year come after 4 years next. like 2020 is a leap year after 2024 will be leap year.Go to the java series.: https://browncodeit.blogspot.com/p/java-programs.… Read More
  • Prime Number in Java - PyapirasThis is a java program to find prime number. it find a number is prime or not .prime  number is a number which is divisible by one or that number not others.Source Code:public class PrimeNumber { public static void main(… Read More
  • Java Data Types - PyapirasThere are two types of data type in java .Primitive data type .Non-Primitive data type.Primitive data types are- int data typeboolean data typefloat data typechar data typedouble data typelong data typeshort data typeNon… Read More

0 comments:

Post a Comment