Pyramid Problem No. 19

 Q.19 Write a C program to print the following triangle:

					*					
				*	*	*				
			*	*	*	*	*			
		*	*	*	*	*	*	*		
	*	*	*	*	*	*	*	*	*	
*	*	*	*	*	*	*	*	*	*	*

Solving in C:

        #include <stdio.h>
        int main(){
            int row,col;
            for(row=1;row<=5;row++){
                for(col=5;col>=1;col--){
                    if(row>=col) printf("*\t");
                    else printf(" \t");
                }
                for(col=1; col<=row-1; col++) printf("*\t");
                printf("\n");
            }
            return 0;
        }	

Comments

Popular posts from this blog

Pyramid Problem No. 85

Pyramid Problem No. 86

Pyramid Problem No. 77