RECENTLY MOST VIEWS
-
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class Jdbc7 ...
-
Harshad Number : In recreational mathematics, a Harshad number (or Niven number), is an integer (in base 10) that is divisible by the sum ...
-
Write a java program to print this numeric pattern 1 2 3 4 8 7 6 5 9 10 11 12 16 15 14 13 class NumericPattern2 {...
-
/* Write a java program in java to reverse each word of string like this input:-"Altaf Java Blog" output:-"Blog Java Alta...
-
package com.cdcis.test; /** * How to count duplicate characters in a string in java? * */ public class Test { public static ...
MOST POPULAR
-
Note: A number will be called DISARIUM if sum of its digits powered with their respective position is equal to the original number. For e...
-
The International Mobile Station Equipment Identity(IMEI) is a number, usually unique, to identify mobile phones, as well as some satellit...
-
/* Write a JAVA program for the given string and take another string and check whether the taken string is substring of given string or no...
-
Harshad Number : In recreational mathematics, a Harshad number (or Niven number), is an integer (in base 10) that is divisible by the sum ...
-
package com.altafjava.sln.test; public class SecondLargestNumber { public static void main(String[] args) { int[] arr={5,20,8,1...
Blog Archive
-
▼
2018
(38)
-
▼
August
(19)
- How to convert string into int primitive data type?
- Write a JAVA program for the given string and take...
- How to find largest number less than a given numbe...
- How to count occurrences of each character of a st...
- How to count occurrences of each character of a st...
- How to find second largest number in an integer ar...
- How to find sum of all digits of a number in java?
- How to find duplicate elements in an array using H...
- How to find duplicate elements in an array?
- Java Program to check two strings are Anagram or not
- How do you check the equality of two inner arrays ...
- How do you check the equality of two arrays in java?
- How to count duplicate characters in a string in j...
- How to find duplicate characters in a string in java?
- How do you remove all white spaces from a string i...
- How do you remove all white spaces from a string i...
- How to print Number Pyramid Pattern in java?
- How to create a pyramid of numbers in java?
- How to reverse a string in java?
-
▼
August
(19)
About
Hello ALTAF
Showing posts with label number-pyramid-pattern. Show all posts
Showing posts with label number-pyramid-pattern. Show all posts
Sunday, August 19, 2018
Thursday, August 16, 2018
How to create a pyramid of numbers in java?
package com.npp.test;
public class Test {
public static void main(String[] args) {
int n=10;
for(int i=1;i<=n;i++)
for(int j=1;j<=n+1;j++)
System.out.print(i>9?j<=n-i+1?" ":i+" ":j<=n-i+1?" ":i+" ");
}
System.out.println();
}
Instead of writing ternery operator we can write this also
if(i>9)
System.out.print(j<=n-i+1?" ":i+" ");
else
System.out.print(j<=n-i+1?" ":i+" ");
Subscribe to:
Posts (Atom)
Program List
- armstrong
- char-occurrances
- check-anagram
- check-duck-no
- check-duplicate-no
- check-endianess-of-os
- check-equality-of-two-arrays
- check-fibonacci-series
- check-harshad-no
- check-kaprekar
- check-keith-no
- check-niven-no
- check-palindrome
- check-prime
- check-prime-no
- check-substring
- check-unique-no
- check-valid-imei
- convert-array-to-list
- convert-string-to-int
- count-duplicate-char-in-string
- count-occurrences-char-of-string
- create-immutable-class
- disarium
- filter-number
- find-1st-non-repeat-char
- find-common-no-in-array
- find-duplicate-char-in-string
- find-duplicate-no-in-array
- find-largest-no-less-than-given-no
- find-palindrome
- find-second-largest-number
- image-store-in-database
- jdbc-program
- number-pyramid-pattern
- numeric-pattern
- remove-duplicate-in-string-array
- remove-white-space-of-string
- reverse-list
- reverse-string
- search-element-in-array
- search-list
- sorting-array
- sorting-list
- sorting-user-defined-object
- string-reverse
- sum-of-all-digits
- swap-2-no
- view-system-properties