Pages

Wednesday, 1 February 2017

Simple Triangle C Language

Simple Triangle C Language Code

While Loop Implementation :

#include<stdio.h>
void main()
{
     int i,j;
     i=1;
     while(i<=5)
     {
           j=1;
           while(j<=i)
           {
                printf("*");
                j++;
           }
           printf("\n");
           i++;
     }
}


 For Loop Implementation : 

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

No comments:

Post a Comment