ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2018 ICSE Computer Science Paper



Share with a Friend

Solved 2018 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Pronic Number - ICSE 2018 Computer Science

 
Write a program to input a number and check and print whether it is a Pronic number or not. Pronic number is the number which is the product of two consecutive integers.

Examples:
12 = 3 × 4
20 = 4 × 5
42 = 6 × 7

import java.util.Scanner; class Pronic{ public static void main(String[] args){ Scanner in = new Scanner(System.in); System.out.print("N = "); int n = Integer.parseInt(in.nextLine()); int p = 1; while(p * (p + 1) < n) p++; if(p * (p + 1) == n) System.out.println("Pronic number"); else System.out.println("Not a Pronic number"); } }

Output

 
 OUTPUT 1: 
 N = 12
Pronic number

 OUTPUT 2: 
 N = 20
Pronic number