You are on page 1of 17

Practice paper for the Board Examination March 2018

I. Evaluate the given expressions:-


(1) int a=4, b=2, c=8;
System.out.println (a+b*c%a);
System.out.println (a+b/c+a);
System.out.println (a%b + b%c + b/a + c/b);
(2) int x=2, y=5, z=3;
System.out.println (x*=5);
System.out.println (x+5);
y+=x+=z;
System.out.println (x+" "+y+" "+z);
(3) int m=100, n=200, p=500;
System.out.println (m+n>n-p);
System.out.println (m+p%m==n-100);
System.out.println (! (m*2==n));
System.out.println (m<n & p%m==0);
System.out.println (n%m!=p%p);
(4) String s="Examination";
int a=20, b=19;
System.out.println (s+a+b);
System.out.println (a+b+s);
System.out.println ('A'+'B'+" is the Output");
System.out.println ("Output is "+'A'+'B');
System.out.println ("Output is "+('A'+'B'));
System.out.println ("Output is "+a*b%2);
System.out.println ("Output is "+'a'+5);
System.out.println ('a'+5+"=Output");
(5) (a) int k=5, g=3;
System.out.println (k++ - --g*++k%g++);
System.out.println ("k="+k+"\ng="+g);
(b) int a=2, b=-5;
a*=++a + --b + a--;
System.out.println ("a="+a+" b="+b);
(c) int m=1000, n= 500;
m%=n;
System.out.print (m);
System.out.println (n);
n+=--n + ++m;
System.out.println (m+n);
(d) int a=3; char ch='a';
System.out.println (a++ + ++ch – a++);
System.out.println (a+"\n"+ch);
II. State the return data type and value given by the following expressions:-
(1) System.out.println (1+2*5%3);
(2) System.out.println (1.5 + 2*'b');
(3) char ch='X';
System.out.println (ch++ + 5); System.out.println (--ch);
(4) int m=2, n=10;
System.out.println (m*2==n);
System.out.println (!(m<n && n>m));
(5) System.out.println (Math.pow (2,3));
System.out.println (Math.max ('C', 'G'));
System.out.println ("ABCD"+10+10.5);
System.out.println ("LAPTOP".charAt (0)+ "LENOVO".charAt(1));
System.out.println (Character.toUpperCase ("CLOcK".charAt (3)));
System.out.println (Character.isLetter ('j'));
Scanner sc=new Scanner ("AB CD EF");
System.out.println (sc.next ( ));
System.out.println (sc.nextLine ( )+12);
String s="120", s1="200";
System.out.println (s+s1+Integer.valueOf(s));
III. Write the Output:-
(1) boolean a=true;
if(a)
System.out.println ("Executed");
else System.out.println ("Not Executed");
(2) boolean a=false;
if(a==false)
System.out.println ("Executed");
else System.out.println ("Not Executed");
(3) int a=5, b=10, c=15;
if(a*2==b)
System.out.println (a++ +c%a);
if(a%3==0)
System.out.println (++b*--c/b);
(4) What is the result given by the following code if (a) a=3 (b) a=6
switch(a++)
{
case 3: System.out.println (a+4);
case 2: System.out.println (a-- *2); break;
case 2*3: System.out.println("SIX");
default: System.out.println (a);
}
(5) int m=100;
if(m%2==0)
if(m%10==0)
if(m<100)
System.out.println (m++);
else
System.out.println (m--);
else
System.out.println (++m);
else
System.out.println (--m);
(6) int p=2, q=4;
p*=(p+q)%2==0?p%q:q%p;
System.out.println ("p="+q+"\tq="+q);
IV. Analyze how many times the following loops gets executed and write the output:-
(1) int x=100;
while (x!=0)
{
System.out.println (x);
if(x%6==0)
break; x--;
}
(2) int a=1;
while (true) {
System.out.println (++a);
if(a%5==0) break; }
(3) int m=2, n=5;
while (m<=n)
{
System.out.println (m+" "+n);
m++; n++;
}
(4) int i=0;
while (++i<=10)
{
if(i%2==0)
continue;
System.out.println (i);
}
(5) char ch='z';
do
{
System.out.println (--ch);
if(ch%3==0)
break;
}while (ch>='a');
(6) int i;
for (i=50; i>=10; i-=10)
System.out.println (i);
System.out.println (++i*10);
(7) for (int x=2; ; x+=2)
{
System.out.println (++x);
if (x==6)
break;
}
(8) for (int i=3; i>=1; i--) {
for (int j=i; j>=1; j--)
System.out.print(j);
System.out.println(); }
(9) for (int k=5; k<=50; k+=10)
{
if (k%2==0)
continue;
System.out.println (k);
}
(10) String s="EXAM"; for (int a=0;a<s. length();a++)
{
char c=s.charAt(a);
System.out.print (++c);
}
V. Write the Output:-
(1) String s1="BASIC", s2="BASE";
System.out.println (s1.length ()+ s2.length());
System.out.println (s1.charAt(0)==s2.charAt(0));
System.out.println (s2.charAt (s1.length ()-3));
System.out.println (s1.startsWith (s2.substring (0,2)));
System.out.println (s1.concat (""+s2));
System.out.println (s1.substring (0,1).concat (s2.substring (1)));
System.out.println (s1.compareTo(s2));
System.out.println (s1.toLowerCase ( ).charAt (3));
System.out.println (s2.substring (2, s2.length()));
System.out.println (s1.replace (s1.substring (0,3), "MAG"));
(2) String x="I.C.S.E Examination 2019";
System.out.println (x.indexOf('.')+x.lastIndexOf('.'));
System.out.println (x.indexOf ('A')+ x.indexOf ('a'));
System.out.println (x. substring (2, 6));
System.out.println (x. substring (8));
(3) System.out.println (Math. pow ("ICICI".indexOf('I',1), "ICICI".lastIndexOf('C')));
System.out.println (Math.abs(-12.34)+Math.sqrt(625));
System.out.println (Math.ceil (-2.3)+Math.floor(-5.6));
System.out.println (Math.max (Math.ceil(3.66), Math.rint(8.5)));
System.out.println ((int)(Math.random ()*10));
System.out.println (Math.min ('1', Math.min('a', '3')));
System.out.println (Math.round (5.78)+Math.round (5.4));
(4) String s="YEAR 2019";
System.out.println (Character. isLetterOrDigit(s.charAt(5)));
System.out.println (Character. isWhitespace(s.charAt(4)));
System.out.println (Character.toLowerCase(s.charAt(3)));
System.out.println (Integer.parseInt(s.substring(5))+10);
(5) String m="120", n="100";
System.out.println (m+n);
System.out.println ("Result="+Integer.valueOf(m)%Integer.valueOf(n));
System.out.println (Float.parseFloat(m));
(6) double x=12.35; int y=12;
String s1=String.valueOf(x);
String s2=Integer.toString(y);
System.out.println(s1+s2);
(7) char ch='6', ch1='S';
System.out.println (Character.toString(ch)+String.valueOf(ch1));
(8) int arr[]={12,10,5,8,7};
System.out.println (arr.length + arr[arr.length-1]);
System.out.println (arr[0]++ + --arr[2]*arr[4]);
for (int i=0;i<arr.length;i++)
System.out.print (arr[i]+ " ");
System.out.println ("\n is the output");
(9) char x[]={65,66,67,68,32}; Note: 32 is the ASCII of space char
System.out.println (x[0]+ " "+x[3]);
System.out.println (++x[1]);
System.out.println (x[1]);
for (int i=0;i<x.length;i++)
System.out.println(x[i]);
(10) String st[]={"MARS", "EARTH", "MOON", "MERCURY"};
System.out.println (st.length);
System.out.println (st[0].length()>st[2].length());
System.out.println (st[1].equals(st[1]));
System.out.println (st[3].charAt(0)==st[2].charAt(0));
System.out.println (st[0].charAt(0)+ ""+st[1].charAt(0));
System.out.println (st[1].charAt(1)+st[2].charAt(0));
System.out.println (st[2].length()+st[3].length());
(11) boolean b[]={true, false, false, true};
if(b[0]==b[b.length-1])
System.out.println(b[0]=false);
else
System.out.println(b[3]=false);
(12) double x[]={1,2,3,4.56}; int a=2;
System.out.println(x[1]);
System.out.println (Double.toString(x[2]+x[1]));
System.out.println (x[0]+x[1]*x[2]);
System.out.println (++x[++a]);
VI. Study the given code and answer the questions that follow:-
class code
{
static int m, n=10; int x, y;
public code (int a, int b)
{
x=a; y=b;
}
public int Calc ()
{
int result=m*n;
return result;
}
public void Display ()
{
System.out.println(m+"\n"+n);
System.out.println(x+" "+y);
}
public static void main()
{
code obj=new code(12,24);
int output=obj.Calc();
System.out.println (output);
Obj.Display();
}
}
Questions:-
(1) Name the class variables.
(2) Name the instance variables.
(3) Name the formal parameters.
(4) Name the actual parameters.
(5) Name the access specifiers used in the above code.
(6) Which unit of a class gets invoked when object is created?
(7) What is the output of the above program?
(8) What is the use of new keyword?
(9) Name the method call statements.
(10) Name the local variables used in the above code.
(11) Name the class name and its object.
(12) Differentiate between static and non-static data members.
(13) What is the role of return keyword?
(14) What does void signify?
(15) Name the operators used in the above code.
(16) Name the separators used in the above code.
(17) Differentiate between print () and println()
(18) What is the scope and life time of the variable result in the above code?
(19) What is the scope and life time of the variables m and n?
(20) What is the scope and life time of the variables x and y?
VII. Complete the following:-
(1) 'A' + 'B' = ______________.
(2) 'a'+12 = ____________.
(3) "A"+'A' = __________.
(4) "AB"+12+'A' = ___________.
(5) (char)( 'A'+5) = ___________.
(6) 1 +2*4 = _____________.
(7) 1/2 + 1%2 = __________.
VIII. Rewrite as directed:-
(1) Using single if statement:
if(code=='G')
System.out.println("Green");
if(code=='g')
System.out.println("Green");
(2) Using switch statement:
if(city.equals("BENGALURU"))
System.out.println ("Garden City");
else if(city.equals("JAIPU"))
System.out.println ("Pink City");
else if(city.equals("KOLKATA"))
System.out.println ("City of Joy");
else
System.out.println("City unavailable");
(3) Using Ternary expression:
switch(colour)
{
case 'R':
case 'r': System.out.println("RED"); break;
case 'G':
case 'g': System.out.println("GREEN"); break;
case 'B':
case 'b': System.out.println("BLUE"); break;
default: System.out.println("Invalid Input");
}
(4) Using if else if statement:
String Roman=n==1? "I":n==2? "II": n==3? "III":n==4? "IV":"Invalid input";
System.out.println (Roman);
(5) Using if else statement:
if(a%2==0)
System.out.println("EVEN");
if(a%2==1)
System.out.println("ODD");
(6) Using nested if statement:
if(a>=10 && a<=20)
System.out.println("Number in range");
else
System.out.println ("Number not in range");
(7) Using while loop:
for (int x=1, y=2; x<=5 & y<=6; x++, y++)
System.out.println (x+"\n"+y);
(8) Using do…while loop:
int a=100;
for (; ; a=a-10)
{
if(a%4==0)
continue;
System.out.println (a);
}
(9) Using for loop:
int p=20;
while(true)
{
System.out.println (p);
if(p%3==0)
break;
p--; }
IX. Write Java Statements:-
(1) Assign the following literals to different variables of requisite data type:
-78, '@', "ICSE", false, 23.56F
(2) To display the text with quotes: "BEST OF LUCK".
(3) To display the values of a and b in the same line with a space using 2 output statements.
(4) To display the values of x and y in different lines using 1 output statement.
(5) To swap the values of a and b using third variable.
(6) To swap the values of m and n without using third variable.
a+b ab
(7) Convert × as Java expression.
a−b ba
2
−b±√b −4ac
(8) Convert as Java expression.
2a
(9) To find the sum of post-increment of x and pre-decrement of y.
(10) To find the sum of quotient and remainder after dividing x by y.
(11) To convert the character ch to its ASCII code using implicit conversion.
(12) To convert the result of x+y*z to integer type using explicit conversion.
(13) To find the result of p raised to q.
(14) To find the sum of square root of x and cube root value of y.
(15) Using Ternary operator, check the value of a is matching with b.
(16) Check x is a perfect cube.
(17) Empty while loop and Empty for loop.
(18) Infinite do…while loop and Infinite for loop.
(19) To check ch is an alphabet and uppercase.
(20) To check x is even using logical NOT operator.
(21) To check the value of x is more than y and z, but equal to m.
(22) To check the length of string x is more than string y.
(23) To extract the 5th character of the string m.
(24) To find the product of position of first space and last space in the string str.
(25) To extract the last 3rd character from the string y.
(26) To check whether the first 3 characters of string x starts with the string y.
(27) To find the greater string among x and y.
(28) To check the strings p and q matching exactly.
(29) To join strings a, b and c with space between using a library function.
(30) To check the first character of the string s is a capital alphabet.
(31) To find the highest integer among x, y and z using a library function.
(32) To find the sine value of the degree x.
(33) To change the magnitude of the variable x.
(34) To find the natural logarithm of a.
(35) To convert the string "12" to integer.
(36) To convert the number 4.5 to String.
(37) To convert the character ch to String.
(38) To read a word using Scanner class method.
(39) To read an integer using Scanner class method.
(40) To read a character using Scanner class method.
(41) To read a line of text using Scanner class method.
(42) To store any 5 consonants in an array of appropriate data type.
(43) To create a character array of size 100.
(44) To convert the character array to string.
(45) To assign the string "XBOX" using new keyword.
(46) To check the first element of a char array x[] is a lowercase vowel.
(47) To find the length of a string element present at the last index position of am array arr[].
(48) To copy first 3 elements of an array x[] to array y[].
(49) To create an object Samsung of class Mobile.
(50) Define a default constructor for a class ABC and initialize the data members String x
and char y to their default values.
(51) Define a parameterized constructor for Q 50.
(52) Create an object to invoke the default constructor in Q50.
(53) Create an object to invoke the parameterized constructor in Q51.
(54) To access the non-static data member int x; in a static method of class Sample.
(55) To access the static variable static int a; of class ABC in another class and same class.
(56) To invoke the given method:
static String Manipulate(String x, char m, char y)
{
x=x.replace(x, y);
return x;
}
(57) To call the class String from the package lang.
(58) To access all the classes present in the package B which is a sub-package of A.
(59) To create a package Network.
(60) Write a function prototype of the function Execute which accepts an integer argument
and returns 0 or 1.
(61) Write a function prototype of the method Sum which accepts a String array st[] and
returns the sum of the lengths of all the string elements present in the array st[].
(62) Write a function prototype of the function check which accepts 2 string arguments and
checks the equality between the strings.
X. Calculate the memory space occupied by the following:-
(1) byte x; (2) float y (3) String s="MOZILLA FIREFOX" (4) char ch='$'
(5) Consider the class:
class Purchase
{
int price;
double discount;
public static void main()
{
Purchase P=new Purchase();
}
} Find the capacity of the object P.
(6) (i) int x[]=new int[100]; (ii) char c[]=new char[5];
XI. Debug the following:-
(a) int x=12.3;
(b) char c="3";
(c) string a="12345";
(d) int a;b;c;
(e) double a, int b, char c;
(f) If(x=10)
System.out.println("Equal to 10")
(g) For (x=1, x<=10,x++)
System.Out.Print(x);
(h) int x=(1,2,3,4,5)
(i) int []y=New Int[10];
(j) Class Bug
{
int x;
Void Input(int a)
{
Int x=a;
}
}
(k) void CALC(int x, int y)
{
If(x>y)
Return True;
Else if(y>x)
Return True;
Else
Return False;
XII. Identify Syntax or logical or runtime error:-
(1) int x=90, y=7;
char c=x+y;
(2) int x[]={1,2};
System.out.println(x[x.length]);
(3) System.out.println ("Hello World")
(4) int a;
int a=10;
char op='+'; int a=3, b=5;
(5) switch(op)
{
case '+': System.out.println (a-b);
break;
case '-': System.out.prinln(a+b);
break;
}
(6) if (marks<0)
System.out.println ("Valid Marks");
else if(marks>0&&marks<101)
System.out.println("Invalid Marks");
(7) String s="Agriculture";
System.out.println (s.charAt(4-s.length()));
(8) int x=100, y=10;
System.out.println (x/(x%10));
(9) int x=-27;
System.out.println (Math.sqrt(x));
(10) switch(x)
{
case 1: System.out.println("****”); break;
case 1: System.out.println ("@@"); break;
case 2: System.out.println ("&&&");
}
(11) String s="ABCD";
System.out.println (s.substring (s.length()-2, s.length()+1));
(12) Scanner sc=new Scanner (System.in);
System.out.println ("Enter an integer");
int x=sc.nextDouble();
_________________________
Programs
1. Define a class Telcall having the following description
Data Members/Instance Variables:
phno – phone number name- name of the customer
n – number of calls made amt- bill amount
Member functions/methods:
(i) Telcall() : parameterized constructor to assign values to phno, name and n.
(ii) void compute()- to calculate the phone bill amount based on the slab give below:

Number of calls Rate


1-100 Rs. 500/- rental charge only
101-200 Rs. 1.00/- per calls + rental charge
201-300 Rs. 1.20/- per calls + rental charge
Above 300 Rs. 1.50/- per calls + rental charge
Note: The calculation need to be done as per the slabs.
(iii) void display() – display the details in different lines.
Write a main() to create an object and call the functions.
2. Define a class Employee having the following description:
Data Members/Instance variables:
String empname – employee name int empcode – employee code
double basicpay – basic pay double hra – house rent allowance
double da – dearness allowance double salary – basicpay+hra+da
double Total- total salary
Member functions/methods:
(i) default constructor to initialize the data members to their default values.
(ii) void input()- accept values for empname, empcode, basicpay.
(iii) void compute()- calculate the salary as per the given rules below:
Salary=BasicPay+HRA+DA
HRA=30% of basicpay
DA=40% of basicpay
If the employee code for the employee is <=15 then a special allowance will be added if
the salary is <=15000. The special allowance will be 20% of the salary(basicpay+hra+da).
Hence the Total Salary= salary + 20% of the salary
If the employee code for the employee is >15 then a special allowance will be Rs. 1000.
Hence the total salary for the employee will be calculated as
Total Salary= salary+ special allowance
(iv) void display ()- display the details as given below:
Empcode Name Salary Total Salary
Xxxx xxxx xxxxx xxxx
Write a main() to create an object and call the functions.

3. Define a class Hotel having the following description:


Data Members/Instance variables:
String name – person’s name.
String category- Category of room
int days- number of days stayed.
int amount – Bill Amount
Member functions/methods:
(i) void input()- accept details for name, n and category.
(ii) void calculate()- Find the bill amount based on the given tariff:

Category Tariff
Semi Deluxe Room Rs. 2,500/- per day
Deluxe Room Rs. 3,500/- per day
Super Deluxe Room Rs. 5,000/- per day
(iii) void display ()- display the details in different lines.
Write a main() to create an object and call the functions.
4. Define a class Library having the following description
Data Members/Instance Variables:
String name – user name int days- days book returned late
double fine – fine amount
Member functions/methods:
(i) default constructor to initialize the data members to default values
(ii) void accept()- to accept details for name and days
(iii) void calc()-calculate the fine amount as given below:
Number of days Fine
First 5 days 40 paise per day
Next five days 65 paise per day
Above 10 days 80 paise per day
(iv) void output() – display the details in a tabular format.
Write a main() to create an object and call the functions.
5. Define a class Sales_Purchase having the following description:
Data Members/Instance Vriables:
int price- showroom price of the car. String name – User Name
int n- number of years the car used.
double dep_Value – depreciated value.
Member Functions/methods:
void input() – to accept values for name, price and n
void calculate()- calculate the depreciated values as per
Number of years Rate of depreciation
1 10%
2 20%
3 30%
4 50%
Above 4 years 65%
Write a main() to create an object and call the functions.
6. Design a class to overload the function Pattern() as follows:
(i) void Pattern(int n)- To create the following pattern based on n value.
For Example if n is 5, then output is
1 3 5 7 9
3 5 7 9 11
5 7 9 11 13
7 9 11 13 15
9 11 13 15 17
(ii) void Pattern(String s) – To create the followed based on the word.
For Example: If s is "CYCLE"
Output: CYCLE
YCLE
CLE
LE
E
Write a main() method to create an object and call the functions.
7. Design a class to overload the function Series () as follows:
(i) void Series(int n) – to display the given series upto n terms.
For Example: If n is 5, then Output is 0, 3, 8, 15, 24
(ii) double Series()- calculates and returns the sum of the given series:
1 3 5 7 9
Sum= − + − +
2 4 6 8 10
Write a main() method to create an object and call the functions.
8. Design a class to overload the function Manipulate() as follows:
(i) String Manipulate(String s)- return a new string after converting the first and the last
character to uppercase.
(ii) String Manipulate(String s, char c)- returns a new string after removing the character c
present in the string.
9. Design a class to overload the constructor function Calc as follows:
(i) public calc() – calculates and displays the sum of integers in the range -10 to -20
(ii) public calc(int a[])- calculates and displays the sum and product of all the elements
present in the array a[].
Write a main() to invoke the above constructors.
10. Design a class to overload the function Split() as follows:
(i) void Split(int x)- if x is two-digit then display the digits of x with space between.
Example: If x is 12, then Output: 1 2
(ii) void Split(String x)- If x length is even, then split the string into two equal halves and
display.
Example: If x is "SING" then output is SI NG
(ii) void Split(double x)- Split and display the integer and real part.
Example: If x is 1.23 then output is 1 23
11. Using switch statement write a menu driven program to.
1. Pattern 1
2. Pattern 2
Display appropriate error message of the choice is invalid.
Pattern1 Pattern2
EGAMI 54321
GAMI 4321
AMI 321
MI 21
I 1
12. Using switch statement. Write a menu driven program to
1. Series1
2. Series2
Display appropriate error message of the choice is invalid.
1+3 2+5 8+15
Series1: + + ⋯…………..
1×3 2×5 8×15
1 1 1 1 1 1 1 1
Series2: + ( + ) + ( + + ) + ( + ⋯ … … … . )
1 1 2 1 2 3 1 10
13. Using switch statement. Write a menu driven program to
1. To check the input number is a perfect cube.
[A number is called perfect cube, if the product of its cube root value is equal to the
input]
Example: 27 is perfect cube. Cube root of 27 is 3, where 3 x 3 x 3=27
2. To check the input number’s ending digit is divisible by 3.
Display appropriate error message of the choice is invalid.
14. Using switch statement. Write a menu driven program to
1. Display special characters from the input string.
2. Display the string in the given format:
If String is JAVA
JAVA
AVAJ
VAJA
AJAV
Display appropriate error message of the choice is invalid.
15. Using switch statement write a menu driven program to.
1. Pattern 1
2. Pattern 2
Display appropriate error message of the choice is invalid.
Pattern1 Pattern2
A* 1
A*B* 01
A*B*C* 101
A*B*C*D* 0101
A*B*C*D*E* 10101
Display appropriate error message of the choice is invalid.

16. Write a Program to input a string and convert to lowercase and encode the string by
replacing each alphabet with the next alphabet in the alphabetical order.. If the alphabet
is z then replace it with the alphabet a. digits and special characters will remain the
same.
Example: If Input is Welcome 2019 Output: xfmdpnf 2019
17. Write a Program to input a string and convert to uppercase and check and display
whether the string is a UNIQUE String or not. The String is called Unique, when
characters present in the string are not repeated.
Example: Input: COMPUTER Output: It is an unique string.
18. Write a Program to input a sentence and display that are palindrome.
For Example: Input: Mom and Dad spoke in Malayalam.
Ouput: Mom Dad Malayalam
19. Write a Program to input a sentence and display the starting letter of each word in
uppercase. For Example: Input: Universal Serial Bus Output: USB
20. Write a Program to input a string and check whether it is a prime string or not. A string is
called prime string if the total number of characters in a string is a prime number.
Example: If Input is bluej Output: it is a prime string.
21. Write a program to input a number and check and display whether it is a Strontio number
or not. Strontio numbers are those 4-digit numbers when multiplied by 2 gives the same
digit in the hundreds and tens place. Example: 1386 is a Strontio number.
1386 x 2 = 2772 where the digit in the in the units and hundreds place is same.
22. Write a program to input a number and check whether it is a kaprekar number or not. A
number is described as follows:
Example 1:
9 is a kaprekar number.
The square of 9 is 81
Add the first two digits and last two digits 8 + 1 = 9 (equal to the input)
Example 2:
45 is a kaprekar number.
The square of 45 is 2025
Add the first two digits and last two digits 20 + 25 = 45 (equal to the input)
Example 3:
703 is a kaprekar number.
The square of 703 is 494209
Add the first two digits and last two digits 494 + 209 = 703 (equal to the input)
And so on…………………………
23. Write a program to input a number and find the sum of the squares of odd digits and sum
of the cubes of the even digits present in the number.
For Example: If input is 12345
Output: Sum of Squares of odd digits = 12+32+52= 1+9+25 = 35
Sum of Cubes of even digits= 23+43=8+64=72
24. Write a program to input a number and :-
(i) Count and display the number of Zero’s.
(ii) Find and display the smallest digit.
(iii) Find the sum of the first and the last digit.
25. Write a program to input a number and display the middle digit from the number only if
the digit count in the number is odd, otherwise display appropriate error message.
For Example: Input: 345 Output: Middle Digit is 4
26. Write a program to store 10 product names, their price quantity in 3 different arrays.
Calculate 10% discount on the total price (price*quantity) for each product and display
the output as
Product Name Price Quantity Total Price Amount after discount
----- ---- --------- -------- --------------
27. Write a program to input marks in a subject for 50 students and calculate:
(i) Subject Total by adding all the students’ marks in the subject.
(ii) Subject average [ SA= SubjectTotal/50]
28. Write a Program to input 10 integer elements in 2 different arrays. Output the elements
which are common in both the arrays at the corresponding index positions.
29. Write a program to input number of kgs of fruits used in 10 different places and the name
of the place in 2 different arrays and calculate
(i) Find the total Kgs of fruits and display.
(ii) Find and display the highest kg of fruits used and the place name.
(iii) Convert kgs to grams and display the result as
Place Kgs Grams
-- -- ---
30. Write a program to input 10 words in an array and
(i) Find and display the length of each word.
(ii) Find and display the word that has highest number of characters.
(iii) Convert and display the first letter of each word to uppercase.
(iv) count and display the no. of vowels in each word.
31. Write a Program to input 10 names and their corresponding course chosen in 2 different
arrays. Search for a name input by the user and display the corresponding course name
along with the student name, if found in the array. Display error message if he name is
not found using Linear Search Technique.
32. Write a Program to input 10 names in an array and search for a name input by the user
and display the index position if found in the array using Binary Search technique.
33. Write a Program to input 10 TV channels and their price in 2 different arrays. Search for
a TV channel name and display the corresponding price if found in the array using
Binary Search technique.
34. Write a Program to input 10 city names and arrange them in reverse alphabetical order
using bubble sort technique. Display the sorted array.
35. Write a Program to input weights of 10 different parcels in an array. Arrange the weights
in ascending order using selection sort technique. Display the sorted array.
36. Write a Program to input 10 state names and the language spoken in two different arrays.
Arrange the state names in ascending order along with the language spoken using
Bubble Sort technique. Display the result as
State Language
---- ------
37. Write a program to input 10 different characters in array and arrange them in descending
order using selection sort technique.

You might also like