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

Sponsored Links



What is the Code for Floyd's triangle in C ??

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 02-01-2010
Member
 
Join Date: Jul 2006
Posts: 218
What is the Code for Floyd's triangle in C ??
  

Hi Friends. I am very new to the C Language. How do i build a Floyd's Triangle in C? Also how can I control the increment of variable in Floyd Triangle. And I how should I initialize? Please provide me the code or explain the logic..

__________________
~*~Silent~Kid~*~
"To The World You May Be Just One Person, But To One Person You May Be The World"
Reply With Quote
  #2  
Old 02-01-2010
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: What is the Code for Floyd's triangle in C ??

I think that you should try the following code for Floyd's triangle :

main void()
{
int num;line_num=1;
printf("enter a number");
scanf("\n");

while (line_num<=n)
{
count=1
while (count<=line_num)
{
printf("%d \t",num++);
count++;
}
printf("\n");
line_num++;
}
}

Hope that you will get the desired answer.
Reply With Quote
  #3  
Old 02-01-2010
Member
 
Join Date: May 2008
Posts: 2,008
Re: What is the Code for Floyd's triangle in C ??

I don't know what exactly you mean when you said "How I control the increment of variable in Floyd Triangle?". I think that you should try this :
Here I have used the three variables, one foe the current number, one containing the number of numbers in the current line, and the third would be a loop from 0 to the second. Here is the code :

int i=1, j=1;
for (k=0; k<j; k++)
printf("%d ",i++);
printf("\n");
j++;
Hope that you were looking for same.
Reply With Quote
  #4  
Old 02-01-2010
Member
 
Join Date: May 2008
Posts: 2,293
Re: What is the Code for Floyd's triangle in C ??

I think that the code told by the katty should work. Since I don't know much about the C Language, I am just guessing. But can anyone tell me the code for the Floyd's triangle in Java.?? I think that some should be knowing this..!! Please help me since I want that for my tutorial.
Reply With Quote
  #5  
Old 02-01-2010
Member
 
Join Date: Nov 2005
Posts: 1,323
Re: What is the Code for Floyd's triangle in JAVA ??

Here is the Code for Floyd's triangle in Java. You can try this code :
import java.io.*;
import java.util.*;
import java.math.*;

public class pyramid{

public static void main(String arg[]){
int i=1,j;
int num = 1;
while(num<=91){
for(j=1; j<=i; j++){
System.out.print (num + " ");
num++;

}
i++;
System.out.print("\n");
}
}
}
Reply With Quote
  #6  
Old 02-01-2010
Member
 
Join Date: May 2008
Posts: 2,384
Re: What is the Code for Floyd's triangle in C ??

I am sure that the code given by the absolute55 should work for the java. Since I have not checked that personally, but seeing the logic I think that it should work. If you are having any error you can post it here. I will try to solve the issue as earlier as possible.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "What is the Code for Floyd's triangle in C ??"
Thread Thread Starter Forum Replies Last Post
How to create rounded triangle in Illustrator? Cheenu Windows Software 5 21-07-2011 08:08 PM
Triangle generator gelsys1208 Software Development 3 13-10-2010 05:32 AM
Triangle using C++ Brake Fail Software Development 4 04-02-2009 11:54 PM
Want To Print Triangle In C++ vishodhan Software Development 1 08-01-2009 09:53 PM
Yellow triangle in the taskbar harakim Windows Software 3 03-10-2008 04:09 PM


All times are GMT +5.5. The time now is 05:15 AM.