0% found this document useful (0 votes)
52 views3 pages

ICSE Class9 Hardest Programs

The document presents 20 challenging programming exercises for ICSE Class 9 students, including tasks such as reversing a number, checking for palindrome numbers, printing the Fibonacci series, and identifying Armstrong numbers. Each program is accompanied by Java code that demonstrates the solution. Additionally, it features a program to print a number pyramid pattern.

Uploaded by

omanisbest100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views3 pages

ICSE Class9 Hardest Programs

The document presents 20 challenging programming exercises for ICSE Class 9 students, including tasks such as reversing a number, checking for palindrome numbers, printing the Fibonacci series, and identifying Armstrong numbers. Each program is accompanied by Java code that demonstrates the solution. Additionally, it features a program to print a number pyramid pattern.

Uploaded by

omanisbest100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

ICSE Class 9 - 20 Hardest Programs for Exam

1. Reverse a Number

import java.util.Scanner;
public class ReverseNumber {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = sc.nextInt();
int rev = 0;
while (num > 0) {
int digit = num % 10;
rev = rev * 10 + digit;
num /= 10;
}
System.out.println("Reversed Number: " + rev);
}
}

2. Check for Palindrome Number

import java.util.Scanner;
public class Palindrome {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = sc.nextInt();
int temp = num, rev = 0;
while (temp > 0) {
int digit = temp % 10;
rev = rev * 10 + digit;
temp /= 10;
}
if (num == rev) {
System.out.println("Palindrome Number");
} else {
System.out.println("Not a Palindrome Number");
}
}
}

3. Print Fibonacci Series

import java.util.Scanner;
public class Fibonacci {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of terms: ");
int n = sc.nextInt();
int a = 0, b = 1, c;
System.out.print(a + " " + b + " ");
for (int i = 3; i <= n; i++) {
c = a + b;
System.out.print(c + " ");
a = b;
b = c;
}
}
}

4. Armstrong Number

import java.util.Scanner;
public class Armstrong {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = sc.nextInt();
int temp = num, sum = 0, digits = 0;
while (temp > 0) {
digits++;
temp /= 10;
}
temp = num;
while (temp > 0) {
int digit = temp % 10;
sum += Math.pow(digit, digits);
temp /= 10;
}
if (sum == num) {
System.out.println("Armstrong Number");
} else {
System.out.println("Not an Armstrong Number");
}
}
}

5. Print a Number Pyramid

public class NumberPyramid {


public static void main(String args[]) {
for(int i = 1; i <= 5; i++) {
for(int j = 1; j <= 5 - i; j++) {
System.out.print(" ");
}
for(int j = 1; j <= 2 * i - 1; j++) {
System.out.print(j);
}
System.out.println();
}
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy