You are on page 1of 6

Class-XII List of Programs (2012-13)

1. Write a function to generate the following series using functions passing the required parameters:a. 1 + x2/2! + x3/3!.........xn/n! b. 1+x2/3!-x3/4!.........xn/n+1! MACROS 2. Write a program to define following macro/constant and their implementation: Area of rectangle Area of square Area of triangle Constant Max = 100 STRING Manipulation 3. Write program to accept a string and display the following menu with out using built-in functions: o String Length. o Palindrome or not. o Vowel count o Change case. ARRAYS & FUNCTIONS 4. Given two arrays of integers A and B of sizes M and N respectively. Write a function named MIX() which will produce a third array named C, such that the following sequence is followed : (HOTS) All even numbers of A from left to right are copied into C from left to right. All odd numbers of A from left to right are copied into C from right to left All even numbers of B from left to right are copied into C from left to right. All odd numbers of B from left to right are copied into C from right to left A, B and C are passed as arguments to MIX(). e.g. : A is {3,2,1,7,6,3} and B is {9,3,5,6,2,8,10}, the resultant array C is {2,6,6,2,8,10,5,3,9,3,7,1,3} 5. Write a function in C++ which accepts an integer array and its size as arguments / parameters and assign the elements into a two dimensional array of integers in the following format (HOTS) If the array is 1, 2,3,4,5,6 If the array is 1,2,3 The resultant 2D array is given below The resultant 2D array is 1 2 3 4 5 6 given below 1 2 3 4 5 0 1 2 3 1 2 3 4 0 0 1 2 0 1 2 3 0 0 0 1 0 0 1 2 0 0 0 0 1 0 0 0 0 0 CLASSES (Wt. 2) 6. Define following class and make menu driven program to call its functions. class array { int a[10]; int n; public: void createarray(); void showarray(); void insertion_Sort();

Computer Science (083)

void Binary_search(); }; 7. Define following class and make menu driven program for doing various operations: class arr2d { int a[10][10]; int m,n; public; void create2D( ); void show2D( ); void show2D_LOWER1( ); void show2D_LOWER2( ); void show2D_UPPER1( ); void show2D_UPPER2( ); void show_Diagonal1( ); void showDiagonal2( ); }; Assuming the2D array to be a square matrix with odd dimensions , i.e 3x3, 5x5,7x7, etc Example if the array content is 543 678 129 Output through the function void show_Diagonal1( ) and void show_Diagonal2( ) should be Diagonal one : 5 7 9 Diagonal two : 3 7 1 . Output through the function void show2D_LOWER1( ) and show2D_LOWER2( ) should be 5 3 67 7 8 129 1 2 9 Output through the function void show2D_UPPER1( ) and show2D_UPPER2( ) should be 543 543 78 67 9 1 Write a program to store the record of an employee with the following details: Private members: Data members EmpNo Integer Name Character Address Character Pin code Character Basic Salary Float HRA Rate Float DA Rate Float PF Rate Float HRA Float DA Float PF Float GROSS Float NET Float Calculate() to calculate HRA, DA, PF, GROSS and net salary

8.

Public: Retempno() function to return empno Retename() function to return employee name Readdata() to accept employee no, name, address, pincode, Basic salary, HRA rate, DA rate and PF rate. Invoke function calculate to calculate HRA, DA, PF, GROSS and net salary Displaydata() to display employee no, name, address, pincode, Basic salary, HRA, DA, PF, GROSS and net salary of the employee Display the following menu for atleast 5 employees: o Create. To accept data of 5 employee o Salary statement. To display payslip of 5 employee o Query in employee number. To accept empno and display relevant data o Query on employee name. To accept employee name and display relevant data. CONSTRUCTOR 9. Write a program to accept the number and compute the factorial. 10. Write a program to generate Tribonacci series. INHERITANCE 11. Consider the classes: class person{ private: char name[20]; protected: int age; public: void readdata(); void displdata(); }; class employee:public person { char department[20]; protected: float salary; public: void read(); void write(); float retsal { return salary;} int retage(){ return age;} int retdep(char *d) { if (strcmp(d,department) == 0) return 1; else return 0;} }; Complete the above classes and write main function having 5 employees (array of employee) and display a menu: 1. Create 2. Search on the basis of age 3. Search on the basis of department 4. Search on the basis of salary

FILE HANDLING 12. Write a program to accept a text file name and display: Number of characters Frequency Table o No of Uppercase character o No of Digits o No of Words o Number of Lines
13.

Write a program to input a text file name, read the contents of the file and create a new file named COPY.TXT, which shall contain only those words from the file (which has been specified by the user) that dont end with a vowel. For example, if the original file contains: Believe in yourself! Have faith in your abilities! Without a humble but reasonable confidence in your own powers you cannot be successful or happy.

Then the text file COPY.TXT shall contain: in yourself! faith in your abilities! Without but in your own powers cannot successful or happy. 14. Consider the following class: class STUD { int Rno; char Name[20]; public: void Enter(){cin>>Rno;gets(Name);} void Display(){cout<<Rno<<Name<<endl;} }; 15. Write the program which displays the following menu and allows following file operations assuming the binary file is containing the objects of the above mentioned class : Create Add Delete (Using Two files) (use remove( ) and rename( ) functions) Display NOTE : Define separate functions for above mentioned operations 16. Declare a structure telerec in C++, containing name (20 characters) and telephone number. Write a program to maintain a binary file of telephone records. The program should allow the following functions on the file: To append records in the file. Display the name for a given telephone number. If the telephone number does not exist then display error message "record not found". Display the telephone number(s) for a given name. If the name does not exist then display error message "record not found". POINTERS 17. Write a program to swap 2 given numbers using pointers. 18. Write a program to create, and display the elements of an integer array using pointers.

19. Declare a structure struct telephone { char tno[9]; char name[10]; }; write the program to do the following : Create an array with 5 elements of telephone type and initialize it with telephone nos. and names of your 5 friends. Create a pointer to telephone array Display the telephone details of your 5 friends using pointer. 20. Try the following program illustrating the use of this pointer #include <iostream> class MyClass { int data; public: MyClass() {data=100;}; void Print1(); void Print2(); }; // Not using this pointer void MyClass::Print1() { cout << data << endl; } // Using this pointer void MyClass::Print2() { cout << "My address = " << this << endl; cout << this->data << endl; } int main() { // First Object MyClass a; a.Print1(); a.Print2(); // Size of doesn't include this pointer cout << sizeof(a) << endl; // Second Object MyClass b; b.Print1(); b.Print2(); }

STACKS and QUEUE 21. Write a program to perform various stack operations like push(), pop(), display() on a STATIC stack. 22. Write a program to perform various queue operations like insert(), delete(), display() on a circular queue (array.) 23. Write a program to perform various stack operations like push(), pop(), display() on a linked stack having following node structure: Roll_no Age Integer Integer

24. Write a program to perform various queue operations like insert(), delete(), display() on a linked queue having 1 integer and 1 floating type data. Struct Node { int x; float y; Node *link; };

You might also like