Write a program that prompt the user to enter an integer from 1 to 9, and displays and upside down pyramid . something like this enter number of lines: 5 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 2 1 2 1
In which Programming language do you want....?
java
i can only go this way * * * * * * * * * * * * * * *
this is my code; for ( i = inpu -1; i >=1 ; i--) { for (int k = 1; k <= i * 2 ; k++) { System.out.print( " " + k ); } System.out.println();
I will try my level best... give me some time ok...
okok sure i will try again for the moment thank you.
if (num < 16) { for (i=1; i<num + 1; i++) { for (j=num-i; j<0; j--) { printf(" "); for (j=i; j<0; j--) { printf(j); } for (j=2; j<i+1; j++) { printf(j); } } } printf(""); } else{ print("The number you have entered is greater than 15."); }
hey did you get it....?
mmm well i had it from big to small but now is inverted from small to big
run: Enter a number: 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 1 2 3 4 1 2 this what i get from my code
and should be run: Enter a number: 5 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 3 2 1 2 3 2 1 2 1
I have the spaces in between okay? the problem is founded here for (int k = 1; k <= i * 2 ; k++) { System.out.print( " " + k);
now is this way i like it more Enter a number: 5 123456789 12345678 1234567 123456 12345 1234 123 12 1
Enter a number: 5 12345 1234 123 12 1 Better, but i can still not make it start from 5 or what ever the number i insert
damnnnnn i do something else but i dont remember how it was before the new code
public class For { public static void main(String[] args) { for(int i=1;i<=9;i++) { System.out.println(); for(int k=9;k>=i;k--) System.out.print(" "); for(int j=1;j<=i;j++) System.out.print(" *"); } } }
i need it inverted!
and with numbers i made once like that and i try it to inverted but it didn;t woork
Heres a few pointers/hints. 1. Find the recurring sequences. 2. Try using different steps or even try while loops. 3. Who said you have to use a constant sentinel?
hihi nobody i'm just trying.
actually i found that while loops are more helpful than fors'. However, im done with this program wanna helo me with other one?
im stuck in the loop. -.-. Im a bad programmer
sure I can help
sorry i went for food havent eat all day
Join our real-time social learning platform and learn together with your friends!