Triangle droit ( Programmation C) - AITIBOUREK

About Author

test banner

Post Top Ad

Responsive Ads Here
Triangle droit  ( Programmation C)

Triangle droit ( Programmation C)

Share This



#include<stdio.h>/*calling the header files*/
int main()
{
int i,j,k,n; /*intializing the variables which are needed*/
printf("Please enter the rows for the right andled triangle \n");
scanf("%d",&n);
/*Loop for the uppart part of the pattern*/
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("*");
}
for(k=n;k>i;k--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
/*loop for lower part */
for(i=2;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
for(k=i;k<n;k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}

Post Bottom Ad

Responsive Ads Here

Pages