Monday, February 19, 2018

Print Heart With Star

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int i,j,n;
clrscr();
textcolor(RED);
cprintf("Enter the value of n:");
scanf("%d",&n);
for(i=n/2;i<=n;i+=2)
{
for(j=1;j<=n-i;j+=2)
{
printf(" ");
}
for (j=1;j<=i;j++)
{
textcolor(j);
cprintf("*");
}
for(j=1;j<=n-i;j++)
{
printf(" " );
}
   for(j=1;j<=i;j++ )
   {
   textcolor(j);
   cprintf("*");
   }
   printf("\n");
}
for(i=n;i>=1;i--)
{
for(j=i;j<n;j++)
{
printf(" ");
}
for(j=1;j<=(i*2)-1;j++)
{
textcolor(j);
cprintf("*");
}
printf("\n");
}

getch();
}
                                                                   Output

2 comments:

  1. This program is potentially useful as a basis for creating a title screen for such applications as "The Excellency," a pocket money checkbook program that I had written in N80-BASIC on an NEC PC-8001 mkII in 1983.

    Had this program, or any counterpart of it, appeared in any of my programming courses in college, I might have enjoyed programming more by expanding on "The Excellency"; unfortunately, nothing similar to it ever did.

    This is one reason that I am now a self-disdaining translator instead of a self-respecting programmer or computer scientist. My professors in computer science in college only respected those who could do research, and one reason that I do not respect myself is that those professors do not respect translators in the manner in which they respect researchers, simply because translators do not do research.

    Personally, I do not understand why it was not possible to fuse art with technology in computer science in creating something of an artistic nature in computer science. If heart-shaped patterns of asterisks were not pedagogically useful enough, at least one of my professors could have taught how to create fractals.

    ReplyDelete