Hi sir, could you give me some clue of this problem.. I'm a beginner sir..


display a pattern of half diamond using for loop in turbo c in vertical..

sample:
if i input a value of 5, the result will b e like this


*
**
***
**
*

the five value is base only in rows..
i already made it like this but there is something because if I input a value like 5 the result is..

*
**
***
****
*****
****
***
**
*

please help me sir...
i want to learn..

Thank You! :)

You could at least post your code so we can see where the problem is from.

Your program (for value 5) appears to draw lines up to 5 characters in length, and then back down. The correct output would be a TOTAL of 5 lines. What is the maximum length of a line in this case? What do you think the program should display if you give it an even value like 6? The program you have so far (without even seeing it) is obviously doing the right thing for -some- value, so you're very close.

#include<stdio.h>
#include<conio.h>
int b,a,c=0,d,rep;
main()
{
  do
    {
    clrscr();
    printf("enter a size**half diamond** ");
    scanf("%d",&a);
    a=a-1; /** calibrate ^^ **/
    clrscr();
    for(b=1;b<=a;b++)
      {
	c=c+1;
	printf("*\n");
	for(d=1;d<=c;d++)
	  {
	    printf("*");
	  }
      }
    for(b=1;b<=a;b++)
      {
	c=c-1;
	printf("*\n");
	for(d=1;d<=c;d++)
	  {
	    printf("*");
	  }
      }
    printf("*\n\n\n");
    printf("GUSTO MO BANG ULITIN? [ESC] = HINDI");/*try again? [ESC] = NO*/
    rep = getch();

  }
 while(rep!=0x1b);
}

reputation pls!!
THANK YOU!

your program should use a factorial

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.