Saturday, November 8, 2008

Learnings of the Week (Rollorata)

THIRD QUARTER!

This week, i was out from the class because of an intensive review for the upcoming Regional Math Quiz Bee, yet, i still have the time to ask my classmates what they did in our Computer Class. They had their reporting on computer programming and i found the problems hard. our group's problem was to Write a program that will display the following pattern, give the value of n.

****

***

**

*

This was the program that we ran:

#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: