--- In [email protected], "jay-r" <[EMAIL PROTECTED]> wrote:
>
> Thanks Corey but I want to do it by using a loop.
>
> -- In [email protected], "Corey McKee" <camckee316@> wrote:
> >
> > you would want to just the cout command to make the shape you
> would want. for example a square:
> >
> > #include <iostream>
> > using namespace std;
> > int main
> > {
> > cout >> "******" >> endl; //remember to count the number of *'s
so
> the box will turn out
> > cout >> "* *" >> endl;
> > cout >> "* *" >> endl;
> > cout >> "******" >> endl;
> >
> > return 0;
> > }
> > do the same for the triangle and rectangle
> >
> > I don't have any advice at this time about your other questions.
> But I hope this will help you with the 1st one
> >
> >
> > From: jay-r
> > Sent: Saturday, July 12, 2008 12:03 AM
> > To: [email protected]
> > Subject: [c-prog] need your help
> >
> >
> > Hello,
> >
> > In the book Accelerated C++, there 2 exercises that I can't
figure
> out
> > how to write the codes.
> >
> > 1. Write a set of "*" characters so that they form a square, a
> > rectangle, and a triangle.....I did the square and rectangle but
I
> have
> > a problem with the triangle.
> >
> > 2. Write a program to generate the product of the numbers in the
> range
> > [1, 10).
> >
> > Another problem is I can't run this...#include <iomanip>...from
a
> Dev-
> > C++ compiler. Any suggestion?
> >
> > Thanks.
> >
> > Jay
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
Hey... bart_pengyou here...
I'm running out of time here in the Internet Cafe, so here's the
code for generating product of numbers in the range [1, 10):
#include <stdio.h>
main(){
int prod = 1, i;
for(i = 1; i < 10; i++) prod *= i;
printf("The product of the integers in the range [1, 10) is %d ",
prod);
}
That's just a factorial function, defined as follows
f(n) = n*f(n-1) if n > 0
f(0) = 1 if n = 0
It's mathematical. Beautiful.