Friday, April 30, 2010

HOLIDAY HOMEWORK 2010

HOLIDAY HOMEWORK- CLASS XII COMPUTER SCIENCE 2010-11

1 Write a program to calculate the sum of rows, columns of a 2D array.
2 Write a program to perform matrix addition.
3 Write a program to perform matrix subtraction.
4 Write a program to perform matrix multiplication.
5 Write a program to enter 3X3 matrix and find maximum value in row wise and column wise respectively.
6 Write a program to enter a string and count the number of Upper case, Lower case and special characters.
7 Write a program to enter a string and count the number of blank spaces.
8 Write a program to enter a string and print every word in a new line.
9 Write a equivalent user defined program to the following library functions:
strcpy ( ) strlen ( )strcat ( )strcmp ( )strrev ( )
10 Write a program to enter integers into 2D array (3X3) and display the array’s mirror image.
11 Write a program to enter n integers into an array of integers and multiply all even position’s number by 2 and all odd position’s integers by 3 and display the result(Note :-array starting from index number 0).
12 Write a program to enter the details of a book (Details given below) in a library and display the details when book number is entered.Book number:Book name:Author’s name:Price of the book:
13 Write a program to double every element of a 2D array of integers.
14 Write a program to exchange first row and last row of a 2D array of integers.
15 Write a program to display each row’s characters of a 2D string in reverse order.
16 Write a program to find the frequency of a person’s name in a 2D string array.
17 Write a function in C++ which accepts an integer array and its size as arguments and swaps the elements of every even location with its following odd location.
Example:
If an array of nine elements initially contains the elements as 2, 4, 1,6,5,7,9,23,10
then the function should rearrange the array as
4,2,6,1,7,5,23,9,10.
18 Answer the questions (i) and (ii) after going through the following class:
class Exam
{ int year;
public:
Exam (int y) {year=y;} //Constructor 1
Exam (Exam & t); ///Constructor 2
};
Create an object, such that it invokes Constructor1.
Write complete definition for Constructor 2.
19 Answer the questions (i) and (ii) after going through the following class:
class Science
{
char Topic [20];
int Weightage;
public:
Science ( ) //Function 1
{
strcpy (Topic, “Optics”); Weightage = 30;
cout<<“Topic Activated”;
}
~Science( ) //Function 2
{
cout<<“Topic Deactivated”;} };
(i) Name the specific features of class shown by Function 1 and Function 2 in the above example.
(ii) How would Function 1 and Function 2 get executed?
20 Answer the questions (i) and (ii) after going through the following class:
class Exam
{
int Marks;
char Subject[20];
public:
Exam () //Function 1
{
Marks = 0; strcpy (Subject,”Computer”);
}
Exam (char S []) //Function 2
{
Marks = 0; strcpy(Subject,S);
}
Exam (int M) //Function 3
{
Marks = M; strcpy (Subject,”Computer”);
}
Exam (char S[], int M) //Function 4
{
Marks = M; strcpy (Subject,S);
}
};
(i) Write statements in C++ that would execute Function 3 and Function 4 of class Exam.
(ii) Which feature of Object Oriented Programming is demonstrated using Function1, Function 2, Function 3 and Function 4 in the above class Exam?
21 Differentiate between Object based programming and Object Oriented programming.
22 Differentiate between a Logical Error and Syntax Error. Also give suitable
examples of each in C++.
23 Name the header file(s) that shall be needed for successful compilation of
the following C++ code :
void main( )
{
char Text[40]; strcpy(Text,”AISSCE”); puts(Text); }

24. Define a class Bank to represent the bank account of a customer with the following specification
Private Members:
- Name of type character array(string)
- Account_no of type long
- Type_of_account ( S for Saving Account, C for current Account) of type char
- Balance of type float
Public Members:
A constructor to initialize data members as follows
- Name NULL
- Account_no 100001
- Type_of_account ‘S’
- Balance 1000
A function NewAccount() to input the values of the data members Name, Account_no,
Type_of_account and Balance with following two conditions
• Minimum Balance for Current account is Rs.3000
• Minimum Balance for Saving account is Rs.1000
A function Deposit() to deposit money and update the Balance amount.
A function Withdrawal() to withdraw money. Money can be withdrawn if minimum balance is as >=1000 for Saving account and >=3000 for Current account.
A function Display() which displays the contents of all the data members for a account.
26 Write a function in c++ which accepts a 2D array of integers, number of rows and number of columns as arguments and assign the elements which are divisible by 3 or 5 into a one dimensional array of integers.
If the 2D array is
The resultant 1D arrays is 12 , 3 , 9 , 24 , 25 , 45 , 9 , 5 , 18
27 Write a function in C++ which accepts an integer array and its size as arguments and interchange the value of each elements as follow :-
before :- 1 2 3 4 5 6 after :- 2 1 4 3 6 5
28. Write a function in C++ which accepts a 2D array of integers and its size as arguments and displays elements which are exactly two digit number.
29 Write a function which will take a string and returns the word count. Each word is separated by a single space.
30 Write a program to count the occurrence of each digit, white spaces, char (blank, tab, newline) & all other characters in a given string.
31 Write a program to search an entered character in the string.
32 Write a program to check whether the given string is palindrome or not.
33 Write a program to check whether the entered two strings are equal or not.
34 Write a program to convert a given the given string into Upper case &Lower case
35 Write a program for the concatenation of two strings
36 Write a program to search an entered word in a given string.
37 Write a program to read a sequence of 20 elements and find its I & II difference.
E.g.: Input  0, 1, 2, 3
D1= 1-0, 2-1, 3-2 = 1, 1, 1. D2= 1-1, 1-1, 1-1 = 0, 0, 0.
38 Write a program to count the occurrence of any two vowels in succession in a line of text.
e.g.: Input please ; Output  ea
39 Write a program to find n value using fact() function which returns the factorial of given number.
i. n =
40 Write a function to print all the prime numbers stored in a 2-D Array.