HOW TO PRINT A DIAMOND
@Kamyanagpal hi please give me your code by pasting it in cb ide and give the link so i can do necessary modifications!
import java.util.Scanner; public class p20 { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); int row = 1; int nst = 1; int nsp = n / 2; int nsq = 0; while (row <= n) { for (int csp = 1; csp <= nsp; csp++) { System.out.print(" “); } for (int cst = 1; cst <= nst; cst++) { System.out.print(”"); } for (int csq = 0; csq <= nsq; csq++) { System.out.print(" “); } for (int cst = 1; cst <= nst; cst++) { System.out.print(”"); } if (row <= n / 2) { nsp–; nsq = nsq + 2; } else { nsp++; nsq = nsq - 2; } System.out.println(); row++; } } }
