Today i am sharing the code for animated heart in c++
#include<conio.h>
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
#include<shashi.h> // header file is created by me which contains the definitions of delay,setcolot,gotoxy,and some others functions
using namespace std;
void heart()
{ int i,j,n=3;
while(1)//for infinately use for the heart to be created.
{ n=3;
delay(500);
setcolor(10);
cout<<"\n\n\t";
for(i=1;i<=n;i++)//loop for upper part
{ setcolor(i+5);//IN Turbo C++ use "textcolor" instead of setcolor
delay(500); //Delay is used to delay the program execution
for(int j=1;j<=(n-i);j++)//loop for space for upper part
cout<<" ";
for(j=1;j<=i+2;j++)//upper part 1st tomb pattern
{cout<<"* ";
setcolor(i+j);
}
for(j=1;j<=2*(n-i);j++)//upper part 2nd tomb pattern
cout<<" ";
for(j=1;j<=i+2;j++)
{cout<<"* ";
setcolor(i+5);
}
cout<<"\n\t";
}
n=11;
for(i=1;i<=n;i++)//loop for rest triangle
{ delay(500);
for(j=1;j<=2*i-j;j++)
{ if(i==1)
cout<<" ";
if(i>1)
cout<<" ";
}
for(j=1;j<=(n-i*2);j++)
{cout<<"* ";
setcolor(i);
}
cout<<"\n\t";
}
gotoxy(20,20);cout<<"::Created by shashi::";//gotoxy is used to set cursor position rowwise and columnwise
delay(500);
system("cls");//In Turbo C++ use clrscr() in place of system("cls")
}//End of while loop
}
int main()
{
heart();
return 0;
}
Code is not working
ReplyDeleteThere is some error
ReplyDelete