import java.util.Scanner;
public class demo {
public static void main(String[] args) {
int i, j, k;
Scanner scan = new Scanner(System.in);
int no = scan.nextInt();
for (i = 0; i < no; i++) {
for (j = (no / 2) + 1; j >= i; j--) {
System.out.print(" ");
}
for (k = 0; k <= i; k++) {
System.out.print("* ");
}
System.out.println();
}
for (i = 0; i < no; i++) {
System.out.print(" ");
for (j = 0; j <= i; j++) {
System.out.print(" ");
}
for (k = no - 1; k > i; k--) {
System.out.print("* ");
}
System.out.println();
}
}
}
Find all the practical at one place of Gujarat Technological University(GTU) With Solutions.
Sunday, June 30, 2019
Write an interactive program to print a diamond shape. For example, if user enters the number 3
Subscribe to:
Post Comments (Atom)
-
A country has a capital city A dining philosopher uses a fork A file is an ordinary file or a directory file Files cont...
-
import java.io.*; public class Dataio { public static void main(String args[]) throws IOException { DataInputStr...
No comments:
Post a Comment