SlideShare a Scribd company logo
1 of 10
Download to read offline
1. Program to print pyramid in C : Pattern 4 :

Output :

*****
 ****
  ***
   **
    *_

Program :


#include <stdio.h>
#include <conio.h>
void main()
{
         int i,j,k,samp=1;
         clrscr();
         for(i=5; i>=1; i--)
         {
                    for(k=samp; k>=0; k--)
                    {
                              printf(" "); // only 1 space
                    }
                    for(j=i; j>=1; j--)
                    {
                              printf("*");
                    }
                    samp = samp + 1;
                    printf("n");
         }
         getch();
}



   2. Program to print pyramid in C : Pattern 5 :

Output :



*****
****
***
**
*_

Program :
#include <stdio.h>
#include <conio.h>
void main()
{
         int i,j;
         clrscr();
         for(i=5; i>=1; i--)
         {
                   for(j=1; j<=i; j++)
                   {
                             printf(" * ");
                   }
                   printf("n");
         }
         getch();
}



   3. Program to print pyramid in C : Pattern 6 :

Output :

   *
  **
 ***
 ****
* * * * *_

Program :

#include <stdio.h>
#include <conio.h>
void main()
{
         int i,j,k,t=0;
         clrscr();
         for(i=1; i<=5; i++)
         {
                    for(k=t; k<5; k++)
                    {
                              printf(" ");
                    }
                    for(j=0; j< i; j++)
                    {
                              printf(" * ");
                              t = t + 1;
                    }
                    printf("n");
         }
         getch();
}
4. Program to print pyramid in C : Pattern 7 :

Output :

    *
   **
  ***
 ****
*****
 ****
  ***
   **
    *_

Program :

#include <stdio.h>
#include <conio.h>
void main()
{
       int i,j,k,samp=1;
       clrscr();
       for(i=1; i<=5; i++)
       {
                 for(k=samp; k<=5; k++)
                 {
                          printf(" ");
                 }
                 for(j=0; j< i; j++)
                 {
                          printf("*");
                 }
                 samp = samp + 1;
                 printf("n");
       }
       samp = 1;
       for(i=4; i>=1; i--)
       {
                 for(k=samp; k>=0; k--)
                 {
                          printf(" ");
                 }
                 for(j=i; j>=1; j--)
                 {
                                   printf("*");
                 }
                 samp = samp + 1;
printf("n");
         }
         getch();
}


    5. Program to print pyramid in C : Pattern 8 :

Output :

Enter number of rows: 5

1
23
456
7 8 9 10
11 12 13 14 15_

Program :

#include <stdio.h>
#include <conio.h>
void main()
{
         int rw, c, no=1 ,len;
         clrscr();
         printf("Enter number of rows: ");
         scanf("%d," &len);
         for(rw=1; rw<=len; rw++)
         {
                   printf("n");
                   for(c=1; c<=rw; c++)
                   {
                             printf(" %2d ", no);
                             no++;
                   }
         }
         getch();
}
6. Program to print pyramid in C : Pattern 9 :

Output :

Enter number of rows: 5

       0
      101
    21012
   3210123
 432101234
5 4 3 2 1 0 1 2 3 4 5_

Program :

#include <stdio.h>
#include <conio.h>
void main()
{
         int no,i,y,x=35;
         clrscr();
         printf("Enter number of rows: ");
         scanf("%d," &no);
         for(y=0;y<=no;y++)
         {
                   goto(x,y+1);
                   for(i=0-y; i<=y; i++)
                   {
                            printf(" %3d ", abs(i));
                            x=x-3;
                   }
         }
         getch();
}



   7. Program to print pyramid in C : Pattern 10 :

Output :

   1
  22
 333
 4444
5 5 5 5 5_

Program :

#include <stdio.h>
#include <conio.h>
void main()
{
        int i, j=5, k, x;
        clrscr();
        for(i=1;i<=5;i++)
        {
                  for(k=1;k<=j;k++)
                  {
                            printf(" ");
                  }
                  for(x=1;x<=i;x++)
                  {
                            printf("%d",i);
                            printf(" ");
                  }
                  printf("n");
                  j=j-1;
        }
        getch();
}



    8. Program to print pyramid in C : Pattern 11 :

Output :

   1
  12
 123
 1234
1 2 3 4 5_

Program :

#include <stdio.h>
#include <conio.h>
void main()
{
         int rw,c,no,spc;
         clrscr();
         printf("Enter number of rows : ");
         scanf("%d", &no);
         for(rw=1; rw<=no; rw++)
         {
                   for(spc=no; spc>=rw; spc--)
                   {
                             printf(" ");
                   }
                   for(c=1; c<=rw; c++)
                   {
                             printf("%2d",c);
                   }
                   printf("n");
}
          getch();
}



    9. Program to print pyramid in C : Pattern 12 :

Output :

      1
    123
   12345
 1234567
1 2 3 4 5 6 7 8 9_

Program :

#include <stdio.h>
#include <conio.h>
void main()
{
         int i,j,k;
         clrscr();
         for(i=1; i<=5; i++)
         {
                    for(j=1; j<=5-i; j++)
                    {
                              printf(" ");
                    }
                    for(k=1; k<=2*i-1; k++)
                    {
                              printf(" %d ",k);
                    }
                    printf("n");
         }
         getch();
}



    10.        Program to print pyramid in C : Pattern 13 :

Output :

ABCDEFGGFEDCBA
 ABCDEFFEDCBA
  ABCDEEDCBA
   ABCDDCBA
    ABCCBA
     ABBA
      A A_
Program :

#include <stdio.h>
#include <conio.h>
void main()
{
         int i,j,asci,spc;
         clrscr();
         for(i=7; i>=1; i--)
         {
                    for(spc=6; spc>=i; spc--)
                    {
                              printf(" ");
                    }
                    asci=65;
                    for(j=1; j<=i; j++)
                    {
                              printf("%2c",asci++);
                    }
                    for(j=i-1; j>=0; j--)
                    {
                              printf("%2c",--asci);
                    }
                    printf("n");
         }
         getch();
}



    11.        Program to print pyramid in C : Pattern 2 :

Output :



*
*   *
*   **
*   ***
*   * * * *_

Program :

#include <stdio.h>
#include <conio.h>
void main()
{
         int i,j;
         clrscr();
         for(i=0; i<5; i++)
         {
                   for(j=0; j<=i; j++)
{
                               printf(" * ");
                     }
                     printf("n");
          }
          getch();
}



    12.        Program to print pyramid in C : Pattern 3 :

Output :

      *
    **
   ***
 ****
* * * * *_

Program :

#include <stdio.h>
#include <conio.h>
void main()
{
         int i,j,k;
         clrscr();
         for(i=1; i<=5; i++)
         {
                    for(j=5; j>=i; j--)
                    {
                              printf(" ");
                    }
                    for(k=1; k<=i; k++)
                    {
                              printf("*");
                    }
                    printf("n");
         }
         getch();
}
13.        Program to all Combinations of characters A,B,C in C : Pattern 1




Output :

AAA AAB AAC ABA ABB ABC ACA ACB ACC BAA BAB BAC BBA BBB
BBC BCA BCB BCC CAA CAB CAC CBA CBB CBC CCA CCB CCC_

Program :

#include <stdio.h>
#include <conio.h>
void main()
{
         char ch1, ch2, ch3;
         clrscr();
         for(ch1='A' ; ch1<='C' ; ++ch1)
         {
                   for(ch2='A' ; ch2<='C' ; ++ch2)
                   {
                            for(ch3='A' ; ch3<='C' ; ++ch3)
                            {
                            printf(" %c%c%c", ch1, ch2, ch3);
                            }
                   }
         }
         getch();
}

More Related Content

What's hot

Structure of c program | CS8251 | Programming in c | Learn Hub
Structure of c program | CS8251 | Programming in c | Learn HubStructure of c program | CS8251 | Programming in c | Learn Hub
Structure of c program | CS8251 | Programming in c | Learn HubLearn Hub
 
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習BopenFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習BAtsushi Tadokoro
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Dr. Loganathan R
 
Антон Полухин. C++17
Антон Полухин. C++17Антон Полухин. C++17
Антон Полухин. C++17Sergey Platonov
 
Алексей Кутумов, C++ без исключений, часть 3
Алексей Кутумов,  C++ без исключений, часть 3Алексей Кутумов,  C++ без исключений, часть 3
Алексей Кутумов, C++ без исключений, часть 3Platonov Sergey
 
Bhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third YearBhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third YearDezyneecole
 
listing output program C
listing output program Clisting output program C
listing output program CAdjievanGestu
 
PROBLEMAS DE PROGRAMACION 2 por jordan puente quinto
PROBLEMAS DE PROGRAMACION 2 por jordan puente quintoPROBLEMAS DE PROGRAMACION 2 por jordan puente quinto
PROBLEMAS DE PROGRAMACION 2 por jordan puente quintoJordan Puente
 
C Program : Sorting : Bubble,
C Program : Sorting : Bubble, C Program : Sorting : Bubble,
C Program : Sorting : Bubble, Meita Jayani
 
C++14 reflections
C++14 reflections C++14 reflections
C++14 reflections corehard_by
 
Practico Nº 2
Practico Nº 2Practico Nº 2
Practico Nº 2Alan007
 

What's hot (20)

week-24x
week-24xweek-24x
week-24x
 
Structure of c program | CS8251 | Programming in c | Learn Hub
Structure of c program | CS8251 | Programming in c | Learn HubStructure of c program | CS8251 | Programming in c | Learn Hub
Structure of c program | CS8251 | Programming in c | Learn Hub
 
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習BopenFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B
 
Ejercicios c#
Ejercicios c#Ejercicios c#
Ejercicios c#
 
Par o impar
Par o imparPar o impar
Par o impar
 
Oop lect 10
Oop lect   10Oop lect   10
Oop lect 10
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2
 
Programs
ProgramsPrograms
Programs
 
Антон Полухин. C++17
Антон Полухин. C++17Антон Полухин. C++17
Антон Полухин. C++17
 
Алексей Кутумов, C++ без исключений, часть 3
Алексей Кутумов,  C++ без исключений, часть 3Алексей Кутумов,  C++ без исключений, часть 3
Алексей Кутумов, C++ без исключений, часть 3
 
Bancocic
BancocicBancocic
Bancocic
 
Bhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third YearBhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third Year
 
listing output program C
listing output program Clisting output program C
listing output program C
 
Pertemuan 2 1
Pertemuan 2 1Pertemuan 2 1
Pertemuan 2 1
 
PROBLEMAS DE PROGRAMACION 2 por jordan puente quinto
PROBLEMAS DE PROGRAMACION 2 por jordan puente quintoPROBLEMAS DE PROGRAMACION 2 por jordan puente quinto
PROBLEMAS DE PROGRAMACION 2 por jordan puente quinto
 
C Program : Sorting : Bubble,
C Program : Sorting : Bubble, C Program : Sorting : Bubble,
C Program : Sorting : Bubble,
 
Dij
DijDij
Dij
 
C++14 reflections
C++14 reflections C++14 reflections
C++14 reflections
 
Aman
AmanAman
Aman
 
Practico Nº 2
Practico Nº 2Practico Nº 2
Practico Nº 2
 

Viewers also liked

Chapter 5.3
Chapter 5.3Chapter 5.3
Chapter 5.3sotlsoc
 
PHP Technical Questions
PHP Technical QuestionsPHP Technical Questions
PHP Technical QuestionsPankaj Jha
 
Top 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and AnswersTop 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and AnswersVineet Kumar Saini
 
Top 100 .Net Interview Questions and Answer
Top 100 .Net Interview Questions and AnswerTop 100 .Net Interview Questions and Answer
Top 100 .Net Interview Questions and AnswerVineet Kumar Saini
 
Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerVineet Kumar Saini
 
C program to write c program without using main function
C program to write c program without using main functionC program to write c program without using main function
C program to write c program without using main functionRumman Ansari
 
สูตรการหาพื้นที่ผิวและปริมาตร
สูตรการหาพื้นที่ผิวและปริมาตรสูตรการหาพื้นที่ผิวและปริมาตร
สูตรการหาพื้นที่ผิวและปริมาตรN'Fern White-Choc
 

Viewers also liked (15)

Tistrukdat1
Tistrukdat1Tistrukdat1
Tistrukdat1
 
Chapter 5.3
Chapter 5.3Chapter 5.3
Chapter 5.3
 
SQL Limit in PHP
SQL Limit in PHPSQL Limit in PHP
SQL Limit in PHP
 
CSS in HTML
CSS in HTMLCSS in HTML
CSS in HTML
 
Browser information in PHP
Browser information in PHPBrowser information in PHP
Browser information in PHP
 
Pagination in PHP
Pagination in PHPPagination in PHP
Pagination in PHP
 
MVC in PHP
MVC in PHPMVC in PHP
MVC in PHP
 
GET and POST in PHP
GET and POST in PHPGET and POST in PHP
GET and POST in PHP
 
Practice exam php
Practice exam phpPractice exam php
Practice exam php
 
PHP Technical Questions
PHP Technical QuestionsPHP Technical Questions
PHP Technical Questions
 
Top 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and AnswersTop 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and Answers
 
Top 100 .Net Interview Questions and Answer
Top 100 .Net Interview Questions and AnswerTop 100 .Net Interview Questions and Answer
Top 100 .Net Interview Questions and Answer
 
Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and Answer
 
C program to write c program without using main function
C program to write c program without using main functionC program to write c program without using main function
C program to write c program without using main function
 
สูตรการหาพื้นที่ผิวและปริมาตร
สูตรการหาพื้นที่ผิวและปริมาตรสูตรการหาพื้นที่ผิวและปริมาตร
สูตรการหาพื้นที่ผิวและปริมาตร
 

More from Vineet Kumar Saini (20)

Abstract Class and Interface in PHP
Abstract Class and Interface in PHPAbstract Class and Interface in PHP
Abstract Class and Interface in PHP
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHP
 
Introduction to Html
Introduction to HtmlIntroduction to Html
Introduction to Html
 
Computer Fundamentals
Computer FundamentalsComputer Fundamentals
Computer Fundamentals
 
Country State City Dropdown in PHP
Country State City Dropdown in PHPCountry State City Dropdown in PHP
Country State City Dropdown in PHP
 
Stripe in php
Stripe in phpStripe in php
Stripe in php
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
Install Drupal on Wamp Server
Install Drupal on Wamp ServerInstall Drupal on Wamp Server
Install Drupal on Wamp Server
 
Joomla 2.5 Tutorial For Beginner PDF
Joomla 2.5 Tutorial For Beginner PDFJoomla 2.5 Tutorial For Beginner PDF
Joomla 2.5 Tutorial For Beginner PDF
 
Functions in PHP
Functions in PHPFunctions in PHP
Functions in PHP
 
Sorting arrays in PHP
Sorting arrays in PHPSorting arrays in PHP
Sorting arrays in PHP
 
Dropdown List in PHP
Dropdown List in PHPDropdown List in PHP
Dropdown List in PHP
 
Update statement in PHP
Update statement in PHPUpdate statement in PHP
Update statement in PHP
 
Delete statement in PHP
Delete statement in PHPDelete statement in PHP
Delete statement in PHP
 
Implode & Explode in PHP
Implode & Explode in PHPImplode & Explode in PHP
Implode & Explode in PHP
 
Types of Error in PHP
Types of Error in PHPTypes of Error in PHP
Types of Error in PHP
 
Database connectivity in PHP
Database connectivity in PHPDatabase connectivity in PHP
Database connectivity in PHP
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
 
Operators in PHP
Operators in PHPOperators in PHP
Operators in PHP
 
Variables in PHP
Variables in PHPVariables in PHP
Variables in PHP
 

Programming in C

  • 1. 1. Program to print pyramid in C : Pattern 4 : Output : ***** **** *** ** *_ Program : #include <stdio.h> #include <conio.h> void main() { int i,j,k,samp=1; clrscr(); for(i=5; i>=1; i--) { for(k=samp; k>=0; k--) { printf(" "); // only 1 space } for(j=i; j>=1; j--) { printf("*"); } samp = samp + 1; printf("n"); } getch(); } 2. Program to print pyramid in C : Pattern 5 : Output : ***** **** *** ** *_ Program :
  • 2. #include <stdio.h> #include <conio.h> void main() { int i,j; clrscr(); for(i=5; i>=1; i--) { for(j=1; j<=i; j++) { printf(" * "); } printf("n"); } getch(); } 3. Program to print pyramid in C : Pattern 6 : Output : * ** *** **** * * * * *_ Program : #include <stdio.h> #include <conio.h> void main() { int i,j,k,t=0; clrscr(); for(i=1; i<=5; i++) { for(k=t; k<5; k++) { printf(" "); } for(j=0; j< i; j++) { printf(" * "); t = t + 1; } printf("n"); } getch(); }
  • 3. 4. Program to print pyramid in C : Pattern 7 : Output : * ** *** **** ***** **** *** ** *_ Program : #include <stdio.h> #include <conio.h> void main() { int i,j,k,samp=1; clrscr(); for(i=1; i<=5; i++) { for(k=samp; k<=5; k++) { printf(" "); } for(j=0; j< i; j++) { printf("*"); } samp = samp + 1; printf("n"); } samp = 1; for(i=4; i>=1; i--) { for(k=samp; k>=0; k--) { printf(" "); } for(j=i; j>=1; j--) { printf("*"); } samp = samp + 1;
  • 4. printf("n"); } getch(); } 5. Program to print pyramid in C : Pattern 8 : Output : Enter number of rows: 5 1 23 456 7 8 9 10 11 12 13 14 15_ Program : #include <stdio.h> #include <conio.h> void main() { int rw, c, no=1 ,len; clrscr(); printf("Enter number of rows: "); scanf("%d," &len); for(rw=1; rw<=len; rw++) { printf("n"); for(c=1; c<=rw; c++) { printf(" %2d ", no); no++; } } getch(); }
  • 5. 6. Program to print pyramid in C : Pattern 9 : Output : Enter number of rows: 5 0 101 21012 3210123 432101234 5 4 3 2 1 0 1 2 3 4 5_ Program : #include <stdio.h> #include <conio.h> void main() { int no,i,y,x=35; clrscr(); printf("Enter number of rows: "); scanf("%d," &no); for(y=0;y<=no;y++) { goto(x,y+1); for(i=0-y; i<=y; i++) { printf(" %3d ", abs(i)); x=x-3; } } getch(); } 7. Program to print pyramid in C : Pattern 10 : Output : 1 22 333 4444 5 5 5 5 5_ Program : #include <stdio.h> #include <conio.h> void main()
  • 6. { int i, j=5, k, x; clrscr(); for(i=1;i<=5;i++) { for(k=1;k<=j;k++) { printf(" "); } for(x=1;x<=i;x++) { printf("%d",i); printf(" "); } printf("n"); j=j-1; } getch(); } 8. Program to print pyramid in C : Pattern 11 : Output : 1 12 123 1234 1 2 3 4 5_ Program : #include <stdio.h> #include <conio.h> void main() { int rw,c,no,spc; clrscr(); printf("Enter number of rows : "); scanf("%d", &no); for(rw=1; rw<=no; rw++) { for(spc=no; spc>=rw; spc--) { printf(" "); } for(c=1; c<=rw; c++) { printf("%2d",c); } printf("n");
  • 7. } getch(); } 9. Program to print pyramid in C : Pattern 12 : Output : 1 123 12345 1234567 1 2 3 4 5 6 7 8 9_ Program : #include <stdio.h> #include <conio.h> void main() { int i,j,k; clrscr(); for(i=1; i<=5; i++) { for(j=1; j<=5-i; j++) { printf(" "); } for(k=1; k<=2*i-1; k++) { printf(" %d ",k); } printf("n"); } getch(); } 10. Program to print pyramid in C : Pattern 13 : Output : ABCDEFGGFEDCBA ABCDEFFEDCBA ABCDEEDCBA ABCDDCBA ABCCBA ABBA A A_
  • 8. Program : #include <stdio.h> #include <conio.h> void main() { int i,j,asci,spc; clrscr(); for(i=7; i>=1; i--) { for(spc=6; spc>=i; spc--) { printf(" "); } asci=65; for(j=1; j<=i; j++) { printf("%2c",asci++); } for(j=i-1; j>=0; j--) { printf("%2c",--asci); } printf("n"); } getch(); } 11. Program to print pyramid in C : Pattern 2 : Output : * * * * ** * *** * * * * *_ Program : #include <stdio.h> #include <conio.h> void main() { int i,j; clrscr(); for(i=0; i<5; i++) { for(j=0; j<=i; j++)
  • 9. { printf(" * "); } printf("n"); } getch(); } 12. Program to print pyramid in C : Pattern 3 : Output : * ** *** **** * * * * *_ Program : #include <stdio.h> #include <conio.h> void main() { int i,j,k; clrscr(); for(i=1; i<=5; i++) { for(j=5; j>=i; j--) { printf(" "); } for(k=1; k<=i; k++) { printf("*"); } printf("n"); } getch(); }
  • 10. 13. Program to all Combinations of characters A,B,C in C : Pattern 1 Output : AAA AAB AAC ABA ABB ABC ACA ACB ACC BAA BAB BAC BBA BBB BBC BCA BCB BCC CAA CAB CAC CBA CBB CBC CCA CCB CCC_ Program : #include <stdio.h> #include <conio.h> void main() { char ch1, ch2, ch3; clrscr(); for(ch1='A' ; ch1<='C' ; ++ch1) { for(ch2='A' ; ch2<='C' ; ++ch2) { for(ch3='A' ; ch3<='C' ; ++ch3) { printf(" %c%c%c", ch1, ch2, ch3); } } } getch(); }