Question : Please do Following.
Ans :
#include<stdio.h>
#include<conio.h>
void main()
{
int no=0,r,c,j=3,k=0,l=0,i=1;
clrscr();
printf("\n Enter No : - ");
scanf("%d",&no);
for(;i<=no;j+=3,k+=3)
{
if(k>=6)
l+=3;
for(r=26+l;r>=23-k;r-=3)
{
if(i<=no)
{
gotoxy(39-k,r);
printf("%d",i++);
}
}
for(c=42-k;c<=42+k;c+=3)
{
if(i<=no)
{
gotoxy(c,23-k);
printf("%d",i++);
}
}
for(r=26-k;r<=26+j;r+=3)
{
if(i<=no)
{
gotoxy(42+k,r);
printf("%d",i++);
}
}
for(c=39+k;c>=39-j;c-=3)
{
if(i<=no)
{
gotoxy(c,29+k);
printf("%d",i++);
}
}
}
textcolor(RED+BLINK);
gotoxy(1,49);
cprintf("Press any key to Exit ....");
gotoxy(59,49);
cprintf("Made By Kaushal Patel.");
getch();
}
Output :
Ans :
#include<stdio.h>
#include<conio.h>
void main()
{
int no=0,r,c,j=3,k=0,l=0,i=1;
clrscr();
printf("\n Enter No : - ");
scanf("%d",&no);
for(;i<=no;j+=3,k+=3)
{
if(k>=6)
l+=3;
for(r=26+l;r>=23-k;r-=3)
{
if(i<=no)
{
gotoxy(39-k,r);
printf("%d",i++);
}
}
for(c=42-k;c<=42+k;c+=3)
{
if(i<=no)
{
gotoxy(c,23-k);
printf("%d",i++);
}
}
for(r=26-k;r<=26+j;r+=3)
{
if(i<=no)
{
gotoxy(42+k,r);
printf("%d",i++);
}
}
for(c=39+k;c>=39-j;c-=3)
{
if(i<=no)
{
gotoxy(c,29+k);
printf("%d",i++);
}
}
}
textcolor(RED+BLINK);
gotoxy(1,49);
cprintf("Press any key to Exit ....");
gotoxy(59,49);
cprintf("Made By Kaushal Patel.");
getch();
}
Output :
0 comments:
Post a Comment