my output its come like
1
1
1
1
1
2
2
2
2
2
3
3
3
3........
pls help I cant find wht problem there in the codeing
--- Update ---
my output its come like
1
1
1
1
1
2
2
2
2
2
3
3
3
3........
pls help I cant find wht problem there in the codeing
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
my output its come like
1
1
1
1
1
2
2
2
2
2
3
3
3
3........
pls help I cant find wht problem there in the codeing
--- Update ---
my output its come like
1
1
1
1
1
2
2
2
2
2
3
3
3
3........
pls help I cant find wht problem there in the codeing
Please post the code you are using and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
If you don't understand my answer, don't ignore it, ask a question.
import java.util.Scanner;
class jag23
{
public static void main(String args[])
{
int n,num=1,c,d;
Scanner in=new Scanner(System.in);
System.out.println("Enter the number of rows of floyd's triangle you want");
n=in.nextInt();
System.out.println("Floyd's triangle");
for(c = 1;c <= n;c++)
{
for(d = 1;d <= c;d++)
{
System.out.println(+num);
num++;
}
System.out.println();
}
} }
Please edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
Make sure the code is properly formatted with indentations.
If you don't understand my answer, don't ignore it, ask a question.
Actually you made mistake on print statement.That is ,
System.out.println(+num);
you use "println". So "ln" means each time iterate the loop print statement is print next line.
so that the output given only vertically
So you used print instead of println like this..
System.out.print(+num);
this will print the correct Floyd's triangle.
what type of out put u want