0% found this document useful (0 votes)
0 views

Class X Foundation LAB Programs

The document contains a series of programming tasks related to arrays, string manipulation, user-defined methods, and revision questions for Class IX. It includes various problems such as traversing arrays, performing searches and sorts, manipulating strings, and creating classes with specific functionalities. Additionally, it covers topics like calculating grades, electricity bills, and displaying patterns.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Class X Foundation LAB Programs

The document contains a series of programming tasks related to arrays, string manipulation, user-defined methods, and revision questions for Class IX. It includes various problems such as traversing arrays, performing searches and sorts, manipulating strings, and creating classes with specific functionalities. Additionally, it covers topics like calculating grades, electricity bills, and displaying patterns.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ARRAYS (1D and 2D)

1. WAP to traverse an integer array and find the sum of the elements in the array.
2. WAP to input 10 numbers into an integer array:
a. Find the largest number.
b. Find the smallest number.
3. WAP to input 10 numbers into an integer array and find the frequency of even numbers and odd
numbers.
4. WAP to perform linear search in a given array.
5. WAP to perform binary search in a given array.
6. WAP to perform sorting in ascending order, using Bubble Sort technique.
7. WAP to perform sorting in ascending order, using Selection Sort technique.
8. WAP to initialize a matrix and find their sum.
9. WAP to find the sum of each row of a 2D array.
10. WAP to find the sum of elements of each of the diagonals in a 3 X 3 integer matrix.
11. WAP to add two 3 X 3 integer matrices.
12. WAP to input numbers into a 3 X 4 integer matrix and display the largest and the smallest
number in it.

STRING MANIPULATION

1. WAP to join the first name and last name and display the result. (concatenation)
2. WAP to input 2 characters and display the character which is alphabetically smaller.
3. WAP to check whether a character is upper/lower case character or a digit.
4. WAP to input a sentence and print all letters in different lines.
5. WAP to input a sentence and find the number of vowels in it.
6. WAP to extract each word from a given sentence and print those words sequentially.
7. WAP to convert all capital letters to small letters and vice-versa in a given string.
8. WAP to input a sentence and find the biggest word present in the sentence. Also, print the
length of the biggest word.
9. WAP to input a sentence and find the words that begin and end with the same letter. Also,
count the number of such words.
10. WAP to input the following sentence: “January 26 is celebrated as the Republic Day of India”
a. Reprint the sentence as: “August 15 is celebrated as the Independence Day of India.”
11. WAP to input a sentence and find the letter that occurs the maximum number of times. Also,
show the total number of occurrences of that letter.
12. WAP to input a string in uppercase and print the frequency of each character.
13. WAP to print all the palindrome words in a given sentence.
14. WAP to accept a String in lower case and change the first letter of every word to upper case.
USER-DEFINED METHODS
1. WAP using functions that add two numbers.
2. WAP to find the average of two integers and return its average of float type.
3. WAP to illustrate local and global variable.
4. Create a class called Number which contains the following class functions:
a. int sumOfDiguts(int n) which returns the sum of the digits in the integer n
b. void call() to accept two integers using Scanner object and find the sum of the digits
of each integer.
5. WAP to check whether a given number is prime or not using functions.
6. WAP to illustrate how call by value and call by reference occurs.
7. WAP to illustrate the accessing technique of member functions within a class.
8. WAP to illustrate the technique of returning an object.
9. WAP to illustrate static and non-static methods.
10. WAP using function overloading to find the area of a rectangle, square, and a circle.

REVISION QUESTIONS OF CLASS IX

1. Write a program by using a class 'Picnic' without any data members but having only functions as per
the specifications given below:
class name: Picnic
void display1( ): To print venue, place, and reporting time.
void display2( ): To print the number of students, name of the teacher accompanying, and bus
number.
Write a main class to create an object of the class 'Picnic' and call the functions display1() and
display2( ).
2. Define a class Book Store having the following specifications:
a. Data Member: Name of the book, author, publication and cost.
b. Member methods:
i. To accept the book details.
ii. To calculate the discount of 13.5% given on all books.
iii. To display the book details.
c. Using a main method and an object, call the above methods

3. In an examination, the grades are awarded to the students in ‘Science’ according to the average
marks obtained in the examination.

Marks Grades
80% and above Distinction
60% or more but less than 80% First division
45% or more but less than 60% Second division
40% or more but less than 45% Pass
Less than 40% Promotion not granted
4. An Electricity Board charges for electricity per month from their consumers according to the units
consumed. The tariff is given below:
Units Consumed Charge

For first 50 units ₹ 0.50/unit


For next 150 units ₹ 0.75/unit
For next 250 units ₹ 1.20/unit
For units above 250 ₹ 1.50/unit
**An additional surcharge of 20% is added to the bill

Write a program to calculate the electricity bill taking consumer's name and units consumed as
inputs. Display the output.

5. Write a program that displays the results of the following evaluations based on the choice entered
by the user:
a) Natural logarithm of the number
b) Absolute value of the number
c) Square root of the number
d) Cube root of the number
e) Random number between 0 and 1

6. Write a menu driven program to accept a number from the user. Check and display whether it is a
Palindrome or a Perfect number or a Prime number or an Automorphic number.

a. Palindrome number: A number is a Palindrome which when read in the reverse order is the
same as the original number. Ex- 11, 101, 151, etc.
b. Perfect number: A number is called Perfect if it is equal to the sum of its factors other than
the number itself. Ex- 6 = 1 + 2 + 3
c. Prime number: A number is said to be prime, if it is only divisible by 1 and itself. Ex- 3, 5, 7,
11....
d. Automorphic number: An automorphic is the number which is contained in the last digit(s)
of its square. Ex- 25 is an automorphic number as its square is 625 and 25 is present as the
last two digits.
7. WAP in Java to find and display the sum of the following series:
a. S = x1 - x2 + x3 - x4 + x5 - x6 + x7 + …. - x20
b. S = a2 + a2 / 2 + a2 / 3 + …… + a2 / 10
1 2 3 4 6
c. S = 2 + 3
+4+5+ 7
+… n terms
d. S = (a*2) + (a*3) + .................... +(a*20)

8. WAP to display the given:


a. 11111
3333
555
77
9
b.
*
**
***
****
*****

c.
12345
1234
123
12
1

d. A
B B
C C C
D D D D
E E E E E
e.

1
12
123
1234
12345

You might also like