C++ logical questions | C++ logical programming questions | logic building programs in c++ | programming logical thinking | logical questions in C
This is the logical C++ program in which we make a tree shape.
The program represent a tree shape through logic . (this can also be done by
hard code like simple cout.).
Source Code
#include
<iostream>
#include
<unistd.h>
using namespace std;
/*Uzair*/
void welcomeScrean(void);
void sleep();
void draw();
int main()
{
system ("color F0");
welcomeScrean();
draw();
return 0;
}
void welcomeScrean(void){
cout<<"\a"
<<"\t*******************************************************"<<endl
<<"\t*******************************************************"<<endl
<<"\t** Welcome To **"<<endl
<<"\t** Draw By * **"<<endl
<<"\t** Program By LEP **"<<endl
<<"\t*******************************************************"<<endl
<<"\t*******************************************************"<<endl
<<endl
<<endl;
sleep();
}
void sleep(){
sleep(1);
for (int i=0 ; i<3;i++)
{
if (i==0)
{
cout<<"\tJust a min ";
}//END
IF i
cout<<"\a.";
sleep(2);
}//
}
void draw(){
int size,i,j,k,k1,p;
cout<<"\n\n\tEnter A No : ";
cin>>size;
cout<<"\n\n\t";
for (i=0;i<size;i++)
{
k
= size-i;
for (j=0;j<k;j++)
{
cout<<" ";
}
for (j=k;j<size;j++)
{
cout<<"*";
}
cout<<"I";
for (j=k;j<size;j++)
{
cout<<"*";
}
cout<<"\n\t";
}
k
= size / 2;
k1
= k / 2;
p
= size-k1;
for (i=0;i<k;i++)
{
for(j=0;j<p;j++)
{
cout<<" ";
}
for(j=0;j<k1;j++)
{
cout<<"*";
}
cout<<"I";
for(j=0;j<k1;j++)
{
cout<<"*";
}
cout<<"\n\t";
}
}
Output of the Program

No comments:
Post a Comment