Heart shape program full solved

This program shows heart shape output.

When program runs and shows output then a Heart is shown as a output.

Code:

‪#‎include‬<stdio.h>
#include<conio.h>
#include <iostream>
using namespace std;
int main()
{
int num;
printf("Please Enter Number : ");

scanf("%d",&num);
cout<<"\n\n";
int g=num*2;
int x=num/2,v=0;
int m=num,n=0;
for(int q=0;q<(num/2);q++)
{
for(int u=0;u<x;u++)
printf(" ");
x--;
printf("*");
for(int o=0;o<v;o++)
printf(" ");
v+=2;
printf("*");
for(int l=0;l<m-1;l++)
printf(" ");
m-=2;
printf("*");
for(int a=0;a<n;a++)
printf(" ");
n+=2;
printf("*");
printf("\n");
}
for(int i=0;i<num;i++)
{
int s,j;
for(s=0;s<=i;s++)
{
printf(" ");
}
printf("*");
for(j=0;j<g-1;j++)
{
printf(" ");
}
g-=2;
printf("*");
printf("\n");
if(i==(num-1))
{
for(int f=0;f<(num+1);f++)
printf(" ");
printf("*");
}
}
getch();
}

Happy Reading!

No comments:

Powered by Blogger.