Arrow Upward
arrowUpward() draws an arrow in the upward direction and it takes 2 parameters:
noOfLines takes the number of lines.
ch takes the character to be displayed in the arrow in upward direction.
Code
#include "stdafx.h"
#include "iostream"
#include "conio.h"
#include "iomanip"
using namespace std;
void arrowUpward(int noOfLines,char ch)
{
for(int i=0;i<noOfLines*2;i=i+2)
{
for(int j=0;j<((noOfLines*2)-2)-i;j=j+2)
cout<<" ";
for(int k=0;k<i+1;k++)
cout<<ch;
cout<<endl;
}
for(int i=0;i<noOfLines+3;i++)
{
for(int j=1;j<=noOfLines;j++)
{
if(j==noOfLines)
cout<<ch<<endl;
else
cout<<" ";
}
}
}
int main()
{
arrowUpward(12,'*');cout<<endl;
_getche();
return 0;
}
Output
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
*********************
***********************
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
0 comments:
Post a Comment