Sunday, September 11, 2011

c program to print triangle of asterisks


See also
Other popular tricky C Sample Codes and language Concept.

6 comments:

  1. Sorry Readers, The header was putted accidentally as I was checking for windows compatibility. It is removed now.

    ReplyDelete
  2. can you suggest me how to print like the below

    *
    *
    *
    *
    *
    *
    *

    ReplyDelete
    Replies
    1. Hi Divya,

      Your requested will be provided by tomorrow EOD. Kindly wait till that.

      Thanks.
      ccplusplus - support

      Delete
    2. Hi Divya,
      Please find the below code,
      =========================================
      #include

      int main ()
      {
      int i = 0, j;
      char *asterisc = "*";
      printf ("How many times you want to print the * ????\n");
      scanf ("%d", &j);
      printf ("printing %d asterisc\n", j);
      for (; i<j; i++)
      {
      printf ("%s\n", asterisc);
      }
      return 0;
      }
      /*
      [ccplusplus@rhel6x64 c]$ gcc print_asterisc.c -o print_asterisc
      [ccplusplus@rhel6x64 c]$ ./print_asterisc
      How many times you want to print the * ????
      5
      printing 5 asterisc
      *
      *
      *
      *
      *
      [ccplusplus@rhel6x64 c]$
      */
      ==================================================

      Delete
  3. 1111111
    1A1AAAA
    1AA1AAA
    1AAA1AA
    1AAAA1A
    1AAAAA1
    1111111

    ReplyDelete
  4. 1111111
    1A1AAAA
    1AA1AAA
    1AAA1AA
    1AAAA1A
    1AAAAA1
    1111111

    ReplyDelete