473,320 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

print triangle

kaleeswaran
132 100+
i would like to know how to print this number like this...
i have tried lot of ways but i can't so help me plzzzzzzzzzzzzzzzzzz
1
10
010
1010
01010
101010
Mar 21 '07 #1
3 3908
r035198x
13,262 8TB
i would like to know how to print this number like this...
i have tried lot of ways but i can't so help me plzzzzzzzzzzzzzzzzzz
1
10
010
1010
01010
101010
What algorithm have you tried? You should write down your intended stepd before you go to the compiler.
Mar 21 '07 #2
kaleeswaran
132 100+
sir!
i am new to java program....
my coding is this
class sam
{
public static void main(String args[])
{
int a=1;
for(int j=0;j<10;j++)
{
for(int i=0;i<=j;i++)
{
if(a==0)
{
System.out.print(" "+a++);
}
else
{
System.out.print(" "+a--);
}
}
System.out.print("\n");
}
}
}
but my output shows wrong like this:
0
01
010
1010
10101
010101
Mar 21 '07 #3
r035198x
13,262 8TB
sir!
i am new to java program....
my coding is this
class sam
{
public static void main(String args[])
{
int a=1;
for(int j=0;j<10;j++)
{
for(int i=0;i<=j;i++)
{
if(a==0)
{
System.out.print(" "+a++);
}
else
{
System.out.print(" "+a--);
}
}
System.out.print("\n");
}
}
}
but my output shows wrong like this:
0
01
010
1010
10101
010101

1.) When posting code please use code tags
2.)Where are the steps I for doing this. Write them down and go over them then compare with what you have written and see if you have followed every step.
3.)Do not call me sir.
Mar 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: coinjo | last post by:
I need to write a program, which takes two inputs: •a value n that represents the number of elementsin the longest row of a triangle. •a character c to be printed in place of each...
9
by: coinjo | last post by:
I need to write a program, which takes two inputs: •a value n that represents the number of elementsin the longest row of a triangle. •a character c to be printed in place of each...
16
by: VISHNU VARDHAN REDDY UNDYALA | last post by:
Hi, Could anyone over here, write a program in C using only for loop to print the following output * *** ***** ******* ********* ***********
0
by: Angela | last post by:
I am using VS.NET 2003 and Crystal 9. I have been told by Crystal, as well as many co-workers who know Crystal really well, that I cannot create the particulat graph I need using Crystal Reports....
2
by: javadkhan | last post by:
Hi All, I am trying to supress the small black triangle that shows up in the menus meaning the menuitem is parent. The reason for that is I drew my own 3D looking triangle in DrawItem using...
1
by: Leo | last post by:
Can someone tell me how to make the sorting triangle on datagrid column header always show up? And which property can change the color of the triangle ? The default color is white. Thanks
0
by: lottoman | last post by:
Hello all, I am trying to draw a triangle on a toolbarbutton to simulate a drop down button without having the extra button beside my drop downbutton. I was successfully able to draw the...
4
by: Anthony Liu | last post by:
There are many ways to represent a binary tree on an ascii screen. 1 / \ 2 3 / \ / \ 4 5 6 7 or
0
geo039
by: geo039 | last post by:
I have a program that takes user input from a textbox. Based on those 3 numbers it will tell them whether it is a right triangle, equilateral triangle or not a triangle. I've written 3 constructors...
14
by: ginevralupin | last post by:
Puhleeeease check this ....... Isnt giving the correct output ... int a,b,c; printf("Enter the sides..."); scanf("%d %d %d",&a,&b,&c); if (a<(b+c)) printf("The triangle is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.