Current location: Hot Scripts Forums » Programming Languages » C/C++ » need help with this triangle asterisks loop


need help with this triangle asterisks loop

Reply
  #1 (permalink)  
Old 04-17-10, 01:27 PM
everyone0 everyone0 is offline
New Member
 
Join Date: Apr 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
need help with this triangle asterisks loop

the required output is :
Code:
 
    *
   ***
  *****
 *******
*********
my work :
Code:
#include <stdio.h>
#include <conio.h>

int main()
{
	int  N,row, column,space;

	printf("Enter the triangle-drawing value n:");
	scanf("%d",&N);
	for (row=1; row<=N; row++)
   {
		for (space=0; space<=N-1; space++)
      {
			printf("*");
		 }
		for ( column = 1 ;  column <= row ; column++ )
      {
			printf(  "*"  );
		}
	printf("\n");
	}
	getch();
}
can anyone help plz ?
Reply With Quote
  #2 (permalink)  
Old 04-22-10, 05:03 AM
Sw@gen Sw@gen is offline
New Member
 
Join Date: Apr 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
At first, I apologize for my bad english.
According to your code, the problem is the condition to print spaces and asterisks is wrong.
Please take a look at a number of spaces, asterisks and order of the line, you will see the relations.


Here it is your modified code.
Attached Files
File Type: txt a.txt (344 Bytes, 292 views)
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
assembly language using notepad++, TASM, and TLINK caierhui Other Languages 0 03-18-10 10:50 AM
infinite loop versus guarded blocks UnrealEd Everything Java 0 11-11-07 02:53 PM
Update multiple rows outside loop - need help ElvansX PHP 1 12-03-06 01:55 AM
Total mysql_num_rows on while loop dihan PHP 2 08-21-05 03:31 PM
While loop jaishalg PHP 1 11-23-04 03:36 PM


All times are GMT -5. The time now is 04:40 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.