View Single Post
  #7 (permalink)  
Old 05-12-2008, 03:58 PM
Irfanerol's Avatar   
Irfanerol Irfanerol is offline
Newbie
 
Join Date: May 2008
Posts: 10
Rep Power: 0
Irfanerol is on a distinguished road
Default Re: Drawing diamond shaped pattern with C

Ups, I've written the input wrong. Sorry for that.
Assuming the input 7 is right.
WingedPanther thank you very much for your explanation. I'll start to writting after this post. It'll work. Thank you very very much.

Code:
#include <stdio.h>

main()
{
	int h, led, inner, star;
	printf("please enter the height of diamond> ");
	scanf("%d", &h);
	
	for ( led = (h-1)/2 ; led<=0 ; led-- )
		printf(" ");
	for ( star = 1 ; star<=2 ; star++ )
			printf("*");
	for ( inner = 0 ; inner<=h-2 ; inner++ )
			 printf(" ");
	for ( led = (h-1)/2 ; led <=0 ; led--) {
			 printf(" ");
			 printf("\n"); }
	system("pause"); 
	return 0;
}
I couldn't understand what's wrong with this code? I think I did everything true?

Last edited by Irfanerol; 05-13-2008 at 06:49 AM.
Reply With Quote