/*to display following
+
+
+
+
+ + + + + + + + +
+
+
+
+
+
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='+';
int i,j,k=0,k1;
for(i=4;i>=0;i--)
{
for(k1=-3;k1<=5;k1++)
{
printf(" ");
}
for(j=1;j<=1;j++)
{
printf("%c",a);
}
printf("\n");
}
for(i=1;i<=9;i++)
{
for(k1=5;k1<=5;k1++)
{
printf(" ");
}
printf("+");
}
for(i=4;i>=0;i--)
{
for(k1=-3;k1<=5;k1++)
{
printf(" ");
}
for(j=1;j<=1;j++)
{
printf("%c",a);
}
printf("\n");
}
getch();
}
1)for this display, we have three parts.
first part is upper
second part is horizontal
third part is vertical form(look circled part)
2) First we display upper part using three loops.
outer loop is for number of rows
inner is for space(constant)
inner most is for display
3) similarly, for second part we have done. ----------------------
program's screenshot:-
----------------------------
program's output:-
+
+
+
+
+ + + + + + + + +
+
+
+
+
+
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='+';
int i,j,k=0,k1;
for(i=4;i>=0;i--)
{
for(k1=-3;k1<=5;k1++)
{
printf(" ");
}
for(j=1;j<=1;j++)
{
printf("%c",a);
}
printf("\n");
}
for(i=1;i<=9;i++)
{
for(k1=5;k1<=5;k1++)
{
printf(" ");
}
printf("+");
}
for(i=4;i>=0;i--)
{
for(k1=-3;k1<=5;k1++)
{
printf(" ");
}
for(j=1;j<=1;j++)
{
printf("%c",a);
}
printf("\n");
}
getch();
}
-------------------
logic in mind:-1)for this display, we have three parts.
first part is upper
second part is horizontal
third part is vertical form(look circled part)
2) First we display upper part using three loops.
outer loop is for number of rows
inner is for space(constant)
inner most is for display
3) similarly, for second part we have done. ----------------------
program's screenshot:-
----------------------------
program's output:-