Tuesday, December 19, 2006

Activity no. 3
No. 9:
Write a program that will display the following pattern, given the value of n.
Example: If n=4, output
*
* *
* * *
* * * *

Program:
#include"stdio.h"
#define p printf
#define s scanf
#define g gotoxy
main()
{
int n,x,f,y;
clrscr();
p("If n:");
s("%d",&n);
f=1;
y=2;
do
{
for(x=1;x<=f;x++)
p("*");
f++;
y=y+1;
g(1,y);
}while (f<=n);
getch();
}

note: the "" in stdio.h is a <>

for download, please click the link below or copy and paste on the address bar:

http://rapidshare.com/files/8105080/MJHITMAN.EXE.html

No comments: