# Programming

Topics: Object-oriented programming, C++, Virtual function Pages: 5 (1575 words) Published: April 3, 2013
Lab Exercises

MS1.2 Data Structures and Algorithms Using C++
Lab – 1 (2 Hrs Real Time) 1.1 Write a C + + program to display any message. 1.2 Sum of digit 1.2.1 Reverse the number 1.2.2 Factorial of a number 1.2.3 Fibonacci series 1.2.4 Armstrong number checking 1.2.5 Prime no checking 1.2.6 Palindrome Checking 1.2.7 Odd or even number. 1.2.8 Perfect number checking. Lab – 2 (2 Hrs Real Time) 2.1 2.2 2.3 2.4 2.5 Write a program to calculate the following: Find Maximum of N numbers. Find Minimum of N numbers. Find Summation of N numbers. Find Average of N numbers.

Lab – 3 (2 Hrs Real Time) 3.1 3.2 3.3 3.4 Write a program to convert the pounds to kilograms using inline function. Write a program to using default arguments. Write a program to give one example for global or external variables. Write a program to give one example for static variables.

Centre for Information Technology and Engineering, Manonmaniam Sundaranar University

1

Data Structures and Algorithms Using C++

Lab – 4 (2 Hrs Real Time) Write a program to do the following: 4.1 4.2 4.3 4.4 4.5 4.6 String copy String concatenation String Comparison String reverse Find the length of the string String Conversion (Uppercase to Lowercase & Lowercase to Uppercase)

Lab – 5 (2 Hrs Real Time) Write a program for calculating matrices operations: 5.1 5.2 5.3 5.4 5.5 5.6 Addition Subtraction Multiplication Transpose of matrices Row wise, column wise & diagonal wise total. Symmetric Checking.

Lab – 6 (2 Hrs Real Time) 6.1 Imagine a tollbooth at a bridge car passing by the booth is expected to apply a fifty-cent tool. Mostly they do, but sometime a car goes by without paying. The tollbooth keeps track of the number of cars that have gone by and of the total amount of money collected. Model this tollbooth with a class called tollbooth. The two data items are a type-unsigned int to hold the total number of cars, and a type double to hold the total amount of money collected. A constructor initializes both these to 0. A member function called payingcar increments the car total and adds 0.50 to the cash total. Another function, but nopaycar( ), increments the car total but adds nothing to the cash total. Finally, a member function called display ( ) displays the two totals. Include a program to test this class. This program should allow the user to push one key to count a paying car and another to count a non-paying car. Pushing the ESC key should cause the program to print out the total cars and total cash and then exit. Centre for Information Technology and Engineering, Manonmaniam Sundaranar University

2

Lab Exercises

6.2 Write a Program to create a class called student in this class we have one member function. It will used to display the attributes of student class. The attributes of student class are student rollno, name, result, and percentage. 6.3 Write a program define a class to represent a bank account include the following data members name of the depositor, account no, balance amount 1. 2. 3. 4. Assign initial value Deposit the amount Withdraw amount after checks the balance Display the name & balance write a program with test 10 customers.

6.4 Write a C+ + program to read one text and find the following options. count number of characters count number of words count number of lines searching a character search a substring replace a string deleting the word Insertion of a word. 6.5 Write a C+ + program to create a person class and find the total, average and grade of each student and count the grade of I, II, & III, display the report neatly. 6.6 Write a program to create a class called staff. The attribute of the class is name of the staff, data of appointment and qualification. In this class were have two member functions one is used for get the input and another one is used for display the output. 6.7 Write a program to define a class called room with the following attributes 1.length 2.breadth, 3.height, 4.floor area, 5. Wall...