Saturday, November 8, 2008

Third gradinG na!!!

LEARNINGS OF THE WEEK
By: Sharra Mae S. Tagaro IV- Rizal


This week, we started our third grading with an assignment on programming, specifically on iterative statements which is to be reported the other day in a manila paper. I was so nervous because our problem is so difficult and there was only the two of us left to make the assignment and that we almost gave up. But because we tried our best and we asked the help of our subject teacher, we made it and I was able to present and explain it in front of the class.What a relief...
This was our assigned problem and answer:
Write a program that will display the following pattern, give the value of n.
So this was the program we run:
#include
#define p printf
#define s scanf
main()
{
int f,q,x,y,t;
clrscr();
p("Enter number:");
s("%d",&x);
p("If n=%d,output\n");
p("\n\n");
q=x;
f=1;
for(y=1,y<=x,y++)
{
for(t=f,t<=q,t++)
{
p("*");
}
p("\n");
q--;
}
getch();
}
The result of this program will look like this:

Enter number: 4

If n=4, output

****

***

**

*

No comments: