Sie sind auf Seite 1von 1

SPIRAL PRINTING

Print the pattern.


4444444
4333334
4322234
4321234
4322234
4333334
4444444
Program:
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main()
{
int n, i, j;
for(i = 0; i < 7; i++)
{
n = 4;
for(j = 0; j < 7; j++)
{
printf("%d", n);
if(i - j >0)
--n;
if(i + j >= 6)
++n;
}
printf("\n");
}
return 0;
}
Output:
4444444
4333334
4322234
4321234
4322234
4333334
4444444

B.BHUVANESWARAN / AP (SS) / CSE / REC - 40

Das könnte Ihnen auch gefallen