Trusted by millions of Kenyans
Study resources on Kenyaplex

Get ready-made curriculum aligned revision materials

Exam papers, notes, holiday assignments and topical questions – all aligned to the Kenyan curriculum.

Using a nested loop write a C program which should print the following result

Using a nested loop write a C program which should print the following result
*
**
***
****
*****
******
*******
********
*********
**********
**********
*********
********
*******
******
*****
****
***
**
*

Answers


Anthony
#include
int main()
{
int a, b;
for ( a=0; a<10; a++)
{
for (b=0; b<=a; b++)
printf("*");
printf("\n");
}
for ( a=0; a<10; a++)
{
for (int b=9; b>=a; b--)
printf("*");
printf("\n");
}
return 0;
}
anmwat answered the question on November 17, 2017 at 06:38

Answer Attachments

Exams With Marking Schemes

Related Questions