Triangle droit ( Programmation C)




#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;
}

Posts les plus consultés de ce blog

Guide pas à pas de la gestion de l’impression dans Windows Server 2008