#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Print Diamond in C program in Decrement loop


    Hello Frndss...
    Its very famous C program every one know Diamond print in C program. in this program firstly take inpute from user then print number of rows as per user required.
    just like user give input '3'
    the result show like this:
    *
    **
    ***
    now i wanna make opposite this program if user give input the result will show like this:
    ***
    **
    *
    its mean we are running decrement loop in this program. i m tying again and again for converting my program like this situation but i failed many times plese check my syntax and guide me what should i chang in syntax for printing decrement result.

    This below syntax is giving output in increment form.
    #include<stdio.h>
    #include<conio.h>

    void main()
    {
    int i,j,num1;
    char ch;
    clrscr();

    printf("\nEnter the number of row: ");
    scanf("%d",&num1);

    for(i = 0; i<=num1; i++)
    {
    for(j = 1; j<=i; j++)
    {
    printf("*");
    }
    printf("\n");

    }
    getch();
    }
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,740
    Rep Power
    1959
    You will have the loop to go from num to 0 and then decreasing i.
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481
    Use the original program, print, turn page upside down.

    mmm. Better still, use your monitor configuration settings to show the display upside down.

    Stand on head?

    Roll your tv?
    Last edited by b49P23TIvg; December 6th, 2013 at 10:01 AM.
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,417
    Rep Power
    1871
    Last edited by salem; December 6th, 2013 at 06:17 PM.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo