Can someone teach me? Thx!!!

Discussion in 'C Programming' started by tianyi, Nov 9, 2004.

  1. tianyi

    tianyi Guest

    I'm the beginner of C programming. And my teacher give a question I don't
    know how to do. Can someone teach me? Thx!!

    The Question is: To print out four *,and skip one line. The print out
    like: ****

    ****

    ****

    ****


    If someone can help me?
     
    tianyi, Nov 9, 2004
    #1
    1. Advertising

  2. tianyi wrote:
    > I'm the beginner of C programming. And my teacher give a question I
    > don't know how to do. Can someone teach me? Thx!!


    Have you tried? Show us what you came up with...

    --
    Jason Whitehurst
     
    Jason Whitehurst, Nov 9, 2004
    #2
    1. Advertising

  3. tianyi

    tianyi Guest

    for (i=1; i<=5; i++)
    {
    for(j=1; j<=i; j++)
    {
    for(K=1; k<=4; k++)
    printf ("*");
    printf("\n");
    }
    printf("\n");
    }
     
    tianyi, Nov 9, 2004
    #3
  4. tianyi

    tianyi Guest

    for (i=1; i<=5; i++)
    {
    for(j=1; j<=i; j++)
    {
    for(K=1; k<=4; k++)
    printf ("*");
    printf("\n");
    }
    printf("\n");
    }
     
    tianyi, Nov 9, 2004
    #4
  5. tianyi wrote:

    > for (i=1; i<=5; i++)
    > {
    > for(j=1; j<=i; j++)
    > {
    > for(K=1; k<=4; k++)
    > printf ("*");
    > printf("\n");
    > }
    > printf("\n");
    > }
    >


    Great!
    Did you try to compile it?
     
    E. Robert Tisdale, Nov 9, 2004
    #5
  6. tianyi

    Mike Wahler Guest

    "tianyi" <> wrote in message
    news:...
    > I'm the beginner of C programming. And my teacher give a question I don't
    > know how to do. Can someone teach me? Thx!!
    >
    > The Question is: To print out four *,and skip one line. The print out
    > like: ****
    >
    > ****
    >
    > ****
    >
    > ****
    >
    >
    > If someone can help me?


    #include <stdio.h>

    int main()
    {
    int i = 0;

    putchar('*'); /* print a single asterisk */

    putchar('\n'); /* print out a 'newline' character */
    /* i.e. a blank line.

    printf("\n\n"); /* print two blank lines */

    for(i = 0; i < 10; ++i) /* print ten asterisks */
    putchar('*');

    printf("%s\n", "***"); /* print three astersiks followed */
    /* by a 'newline' character */
    return 0;
    }

    The above should be enough information for you to figure
    out how to do your assignment.

    -Mike
     
    Mike Wahler, Nov 9, 2004
    #6
  7. tianyi

    tianyi Guest

    thx all you guys' help.

    i'm now know how to correct it.

    thanks again.
     
    tianyi, Nov 9, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kenton Groombridge

    Porting code, need guidance, Thx

    Kenton Groombridge, Aug 14, 2004, in forum: C++
    Replies:
    5
    Views:
    843
    Kenton Groombridge
    Aug 18, 2004
  2. hercules
    Replies:
    6
    Views:
    3,632
    Kevin Bracey
    Dec 2, 2003
  3. Joe Wright

    Re: [OT] "thx"

    Joe Wright, Apr 1, 2004, in forum: C Programming
    Replies:
    0
    Views:
    417
    Joe Wright
    Apr 1, 2004
  4. Nik Coughlin

    How to teach someone HTML/CSS?

    Nik Coughlin, Nov 27, 2008, in forum: HTML
    Replies:
    40
    Views:
    2,442
    dorayme
    Dec 24, 2008
  5. Menghsiu Lee

    can someone teach me this?

    Menghsiu Lee, Jul 21, 2012, in forum: Python
    Replies:
    6
    Views:
    217
    Terry Reedy
    Jul 23, 2012
Loading...

Share This Page