Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 26-08-2009
Member
 
Join Date: Aug 2009
Posts: 76
Left handed right angled triangle with C Program using nested "for" loop

I have recently started learning C programming. I have joined one classes for this. Now I decided to figure out how things works and so I am trying to make a left handed right angle with C Program. But the problem is that I am unable to figure out what the statements would be? I want to use nested "for" loop. Has anyone made a left handed right angled triangle with C Program using nested "for" loop as below?

*
**
***
****
*****
Reply With Quote
  #2  
Old 26-08-2009
Member
 
Join Date: Nov 2008
Posts: 1,054
Re: Left handed right angled triangle with C Program using nested "for" loop

Code:
#include <stdio.h>
void main()
{
int i, j, k, number;
printf ("Enter the number :");
scanf ("%d",&number);
printf ("\n\n");
for(i=1;i<=number;i++)
{
printf("\n");
for(k=number-1;k>=i;k--)
{
printf(" ");
}
for (j=1;j<=i;j++)
{
printf("* ");
}
printf("\t\n");
}
for(i=number-1;i>=1;i--)
{
printf("\n");
for(k=number-1;k>=i;k--)
{
printf(" ");
}
for(j=i;j>=1;j--)
{
printf("* ");
}
printf("\t\n");
}
}
Reply With Quote
  #3  
Old 26-08-2009
Member
 
Join Date: Nov 2008
Posts: 1,221
Re: Left handed right angled triangle with C Program using nested "for" loop

Here is more simpler code for Left handed right angled triangle in C language:

Code:
#include <stdio.h>
void main()
{
	int i,j;
	int n = 0;
	printf ("Please enter the number: ");
	scanf ("%d",&n);
	for (i = 1; i <= n; ++i)
	{
		for (j = 1 ; j <= i; ++j)
		{
			printf ("*");
		}
		printf ("\n");
	}
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Left handed right angled triangle with C Program using nested "for" loop"
Thread Thread Starter Forum Replies Last Post
never Left "Memory Clean" Enabled on BlackBerry Bold 9930 Kaalia Portable Devices 7 16-12-2011 08:09 PM
Aborted XP Home Repair - Now stuck in "setup is being restarted...." loop manishdk Windows XP Support 10 15-10-2010 02:02 PM
Photoshop CS4 "Could not save as...because file is already in use or was left open" Am_Wamika Windows Software 5 11-07-2010 04:30 AM
"configuring updates 3 of 3. 0% complete" reboot loop in Vista - possible fix PA Bear [MS MVP] Windows Update 15 28-12-2009 09:29 PM
Can't open Hotmail msgs, "javascript;" @ lower left Klangpup Vista Help 3 06-07-2008 07:19 AM


All times are GMT +5.5. The time now is 03:12 PM.