The Artima Developer Community
Sponsored Link

Java Buzz Forum
C program to print patterns of numbers,alphabets and stars in a pyramid shape

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
instanceof java

Posts: 576
Nickname: instanceof
Registered: Jan, 2015

instanceof java is a java related one.
C program to print patterns of numbers,alphabets and stars in a pyramid shape Posted: May 15, 2017 3:12 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by instanceof java.
Original Post: C program to print patterns of numbers,alphabets and stars in a pyramid shape
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java

Advertisement
  • We can print *'s  in pyramid pattern using C programming language.
  • We can also print  patterns of numbers and alphabets using C program.
  • Now Check below program that how to print pyramid pattern of * using C program using for loop.
  • C program to print patterns of numbers and stars in a pyramid shape



Program #1 : Write a C program to print pyramid pattern of numbers using for loop.

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(){
  5.     
  6.    int i, j, rows;
  7.  
  8.     printf("Enter number of rows: \n");
  9.     scanf("%d",&rows);
  10.  
  11.     for(i=1; i<=rows; ++i)
  12.     {
  13.         for(j=1; j<=i; ++j)
  14.         {
  15.             printf("* ");
  16.         }
  17.         printf("\n");
  18.     }
  19.         
  20.    getch();
  21.     
  22. }
   
Output:


print pyramid pattern c program

 Program #2 : Write a C program to print pyramid pattern of numbers using for loop.

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(){
  5.     
  6.    int i, j, rows;
  7.  
  8.     printf("Enter number of rows to print pyramid numbers pattern \n ");
  9.     scanf("%d",&rows);
  10.  
  11.     for(i=1; i<=rows; ++i)
  12.     {
  13.         for(j=1; j<=i; ++j)
  14.         {
  15.             printf("%d ",j);
  16.         }
  17.         printf("\n");
  18.     }
  19.         
  20.    return 0;
  21.     
  22. }

Output:

  1. Enter number of rows to print pyramid numbers pattern
  2.  10
  3. 1
  4. 1 2
  5. 1 2 3
  6. 1 2 3 4
  7. 1 2 3 4 5
  8. 1 2 3 4 5 6
  9. 1 2 3 4 5 6 7
  10. 1 2 3 4 5 6 7 8
  11. 1 2 3 4 5 6 7 8 9
  12. 1 2 3 4 5 6 7 8 9 10
  
Program #3 : Write a c program to print patterns of numbers and alphabets

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(){
  5.     
  6.    int i, j;
  7.     char input, alphabet = 'A';
  8.  
  9.     printf("Enter the uppercase character you want to print in last row: ");
  10.     scanf("%c",&input);
  11.  
  12.     for(i=1; i <= (input-'A'+1); ++i)
  13.     {
  14.         for(j=1;j<=i;++j)
  15.         {
  16.             printf("%c", alphabet);
  17.         }
  18.         ++alphabet;
  19.  
  20.         printf("\n");
  21.     }
  22.     
  23.     getch();
  24.     
  25. }

Output:

  1. Enter the uppercase character you want to print in last row:
  2.  I
  3. A
  4. BB
  5. CCC
  6. DDDD
  7. EEEEE
  8. FFFFFF
  9. GGGGGGG
  10. HHHHHHHH
  11. IIIIIIIII

Read: C program to print patterns of numbers,alphabets and stars in a pyramid shape

Topic: Java 9 New Features Tutorial Previous Topic   Next Topic Topic: Java Tutorial: Generics in java | Java Generics [Generic raw type]

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use