Question : WAP in "C" to find out the following output:
#include <stdio.h>
int main ()
{
int i, sp, rows, k = 0, count = 0, count1 = 0;
printf ("Enter number of rows: ");
scanf ("%d", &rows);
for (i = 1; i <= rows; ++i)
{
for (sp = 1; sp<= rows - i; ++sp)
{
printf (" ");
++count;
}
while (k != 2 * i - 1)
{
if (count <= rows - 1)
{
printf ("%d ", i + k);
++count;
}
else
{
++count1;
printf ("%d ", (i + k - 2 * count1));
}
++k;
}
count1 = count = k = 0;
printf ("\n");
}
return 0;
}
Code is very helpful for my project of c
ReplyDeletethanks
ReplyDelete