Print Asterisk Triangle

C program to print the following triangle:







*








***






*****




*******


*********
***********
#include<stdio.h>
 #include<conio.h>
 int main()
 {
  int num=6,r,c,sp;

  for(r=1; num>=r; r++)
  {
   for(sp=num-r; sp>=1; sp--)
       printf(" ");
   for(c=r; c>=1; c--)
        printf("*");
   for(c=r; c>1; c--)
        printf("*");
   printf("\n");
  }

  
  return 0; 
 }

Comments

Popular posts from this blog

Configure IP address on Oracle Linux

Oracle Directory Object

CyclicRotation:Rotate an array to the right by a given number of steps.