hi my name is yonas i am student . i want write a simple c++ program that displays
*
***
*****
*******
**********
and
*
***
*****
*******
*********
***
***
***
***
***
both are different program can you help me please ?
i am waiting your response
thank you
yonas garedew
from Ethiopia
Help me on this c++ code .see the detail below?
IF you have any problem compiling the programs call me at m_gopi_m@yahoo.co.in
//pattern 1.
#include%26lt;iostream.h%26gt;
#include%26lt;conio.h%26gt;
void main()
{
int i,j;
clrscr();
for(i=0;i%26lt;=5;i++)
{
cout%26lt;%26lt;"\n*";
for(j=0;j%26lt;i;j++)
cout%26lt;%26lt;"**";
}
getch();
}
The source for program 2 is,
//pattern2.
#include%26lt;iostream.h%26gt;
#include%26lt;conio.h%26gt;
void main()
{
int i,j;
clrscr();
for(i=0;i%26lt;=5;i++)
{
cout%26lt;%26lt;"\n*";
for(j=0;j%26lt;i;j++)
cout%26lt;%26lt;"**";
}
for(i=0;i%26lt;=5;i++)
cout%26lt;%26lt;"\n***";
getch();
}
Reply:int i,,j
for(i=1,i%26lt;=5,i++)
for(j=0, j%26lt;=i+2, ,j++)
printf("*",%26amp; j)
try this code for the first one i hope i am right use nested loops
Reply:Hi,
i think this 'll b the answer for ur 1st prob
void main()
{
int i,j;
for (i=1;i%26lt;=10;i=i+2)
{
for(j=1;j%26lt;=i;j++)
{
printf("*");
}
printf("\n");
}
}
a slight modification to the above code 'll get u 2 the second output
void main()
{
int i,j;
for (i=1;i%26lt;=20;i=i+2)
{
for(j=1;j%26lt;=i;j++)
{
if(i%26lt;=10)
{
printf("*");
}
else
{
printf("***");
break;
}
}
printf("\n");
}
}
Think this'll help
Ha-p Computing...:)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment