C Program to Print Heart Star Pattern
Heart pattern in C : The following code display, print heart star shape (💓love) pattern using stars (*) in C language. Also we change the colour of heart and we will use the sleep function to make the heart blink
How to print heart pattern in C ?
1. Start
2.Accept the height or size of the heart according to which we are going to print or display the heart star pattern.
3.Print two small triangles using for loop for the upper curve of heart, like the two given below.
The usual inverted triangle
C Program to Print Heart Heart Shape(Love Symbol) Pattern
- #include<stdio.h>
- #include<conio.h>
- #include<stdlib.h>
- #include<dos.h>
- int main(){
- system("cls");
- system("color 04");/*There you are also change the colour
- of heart using the colour code*/
- int i,j,a;
- for(a=0;a<=100;a++){
- system("cls");
- sleep(0.1);/*us also change the time of
- blinking heart symbol*/
- for(i=0;i<=2;i++)
- {
- for(j=0;j<=17;j++)
- {
- if((j>=3-i&&j<=6+i)||(j>=12-i&&j<=15+i))
- {
- printf("*");
- }
- else {
- printf(" ");
- }
- }
- printf("\n");
- }
- for(i=0;i<=9;i++)
- {
- for(j=0;j<=17;j++)
- {
- if(j>=i+1&&j<=17-i)
- {
- printf("*");
- }
- else {
- printf(" ");
- }
- }
- printf("\n");
- }
- sleep(0.1);
- }
- return 0;
- }



0 Comments