how can i make a program with this kind of output..

Enter a number: 5
0
01
012
0123
01234
012345
01234
0123
012
01
0

Answer Posted / salvin

A much more simpler implementation....


public class Test
{
public static void main(String[] args)
{
int no=5;
for(int n=0;n<=no;n++){
for(int m=0;m<=n;m++){
System.out.print(m);
}
System.out.println();
}
for(int n=no;n>=0;n--){
for(int m=0;m<n;m++){
System.out.print(m);
}
System.out.println();
}
}
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the disadvantages of a shell structure?

682


Differentiate between the expression “++a” and “a++”?

691


what is a function method?give example?

1910


i have a written test for microland please give me test pattern

2173


Can we assign integer value to char in c?

609






How can I change their mode to binary?

686


Do you know what are bitwise shift operators in c programming?

577


What are the standard predefined macros?

627


Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop

1707


What is formal argument?

640


When should a far pointer be used?

591


The difference between printf and fprintf is ?

710


Explain spaghetti programming?

678


How can I access an I o board directly?

615


What are loops c?

606