56 : C Program to display star/asterisk isoceles triangle/pyramid sequence 4

Check out the complete list of c-programs : C Program List    





This program prints isoceles triangle/pyramid of asterisks as shown below.

To achive this you need to have 3 nested for loops.

            * 

           *  * 

          *  *  * 

         *  *  *  * 

        *  *  *  *  * 

       *  *  *  *  *  * 

      *  *  *  *  *  *  * 

     *  *  *  *  *  *  *  * 

    *  *  *  *  *  *  *  *  * 

   *  *  *  *  *  *  *  *  *  * 

  *  *  *  *  *  *  *  *  *  *  * 




Variables :

i : Datatype int : Used in for loop1.

j : Datatype int : Used in for loop2.

k : Datatype int : Used in for loop3.



Logic :


 for(i = 0; i <= 10 ; i++) {
        
        for(j = 10; j >= i; j--) {
            printf(" ");
        
            for(k=1; k<=1;k++)
            {
                printf("*");
            }
            
        }
        printf("\n");
    }







/*
 * 1000+ C programs + tutorials
 *
 * 
 * 56_c_program_to_display_asterisk_star_sequence_5
 *  
 *
 *
 *  Created on: Oct 22, 2014
 *  Author: Code2care.org
 */

#include 
//#include <conio.h>

void main() {


//    clrscr();

    int i = 0; //for loop1
    
    int j = 0; //for loop2
    
    int k = 0; //for loop3

    for(i = 0; i <= 11 ; i++) {
        
        for(j = 11; j >= i; j--) {
            printf(" ");
        }
            for(k=1; k<=i*(2-1);k++)
            {
                printf(" * ");
            }
            
        
        printf("\n");
    }
    

//	getch();


}









The best way to learn C programming is to practice more and more of programs . Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.

BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.