Tuesday, September 2, 2014

print the following pattern on the screen using loops


Problem

create a c language program to generate following pattern on the console (screen) using for loop.
*
* *
* * *
* * * *
* * * * *

Solution - Code

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

Sample Output


No comments :

Post a Comment

Note: Only a member of this blog may post a comment.

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact