(triangle -printed program) write a programe that prints the following patterns
ID: 3544750 • Letter: #
Question
(triangle -printed program) write a programe that prints the following patterns separatly one beloww the other use for loops tto generat the patterns, all asterisks (*)should be printed by a single printf statement of the form printf ( "%s", "*"); (this casuses the asterisks to print side by side) .
A) B) C) D
* ********** ********** *
** ********* ********* **
*** ******** ******** ***
**** ******* ******* ****
***** ****** ****** *****
****** ***** ***** ******
******* **** **** *******
******** *** *** ********
********* ** ** *********
********** * * **********
Explanation / Answer
#include<stdio.h>
int main()
{
int i,j,k;
for(i=1;i<=10;i++)
{
for(k=1;k<=i;k++)
printf("*");
printf(" ");
j=11-i;
for(k=1;k<=j;k++)
printf("*");
printf(" ");
for(k=1;k<=j;k++)
printf("*");
printf(" ");
for(k=1;k<=i;k++)
printf("*");
printf(" ");
printf(" ");
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.