c program to print the triangle star(*) pattern

 Description


This program prints the pattern given below. The number of lines in the pattern is read into the variable j. Then the program uses while loop to print the pattern line by line.

//* * * * *
//* * * *
//* * *
//* *
//*

Program


//C program for pattern printing



//C program for pattern printing using asterisk.



//C program for pattern printing using while loop.



#include<stdio.h>

#include<conio.h>

void main()

{

clrscr();

int i=1,j;

printf("Enter the value for n");

scanf("%d",&j);

l:

while(i<=j)

{

printf("* ");

i=i+1;

}

if(j<0)

{

printf("\n");

j=j-1;

i=1;

goto l;

}

getch();

}


No comments: