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

List of Practicals - CSHP101 S/W Lab Based On CSHT 101 Programming Fundamentals - C++

The document contains a list of 34 practical programming problems covering various concepts in C++ like arrays, strings, functions, classes, inheritance, file handling, exception handling, and sorting/searching algorithms. The problems involve writing programs to perform tasks like reversing numbers, calculating series sums, checking palindromes, finding factors and primes, encoding to pig latin, sorting using different algorithms, file operations, matrix and class operations, and exception handling. The programs require concepts like functions, classes, inheritance, pointers, dynamic memory allocation and exception handling.

Uploaded by

Kuldeep Sharma
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
432 views

List of Practicals - CSHP101 S/W Lab Based On CSHT 101 Programming Fundamentals - C++

The document contains a list of 34 practical programming problems covering various concepts in C++ like arrays, strings, functions, classes, inheritance, file handling, exception handling, and sorting/searching algorithms. The problems involve writing programs to perform tasks like reversing numbers, calculating series sums, checking palindromes, finding factors and primes, encoding to pig latin, sorting using different algorithms, file operations, matrix and class operations, and exception handling. The programs require concepts like functions, classes, inheritance, pointers, dynamic memory allocation and exception handling.

Uploaded by

Kuldeep Sharma
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

List of Practicals CSHP101 S/W lab based on CSHT 101 Programming Fundamentals - C++

1. WAP to print the sum and product of digits of an integer. 2. WAP to reverse a number. 3. WAP to compute the sum of the first n terms of the following series S = 1+1/2+1/3+1/4+ 4. WAP to compute the sum of the first n terms of the following series S =1-2+3-4+5. 5. Write a function that checks whether a given string is Palindrome or not. Use this function to find whether the string entered by user is Palindrome or not. 6. Write a function to find whether a given no. is prime or not. Use the same to generate the prime numbers less than 100. 7. WAP to compute the factors of a given number. 8. WAP to print a triangle of stars as follows (take number of lines from user):

* *** ***** ******* *********


9. WAP to perform following actions on an array entered by the user: i) ii) iii) iv) v) vi) Print the even-valued elements Print the odd-valued elements Calculate and print the sum and average of the elements of array Print the maximum and minimum element of array Remove the duplicates from the array Print the array in reverse order

The program should present a menu to the user and ask for one of the options. The menu should also include options to re-enter array and to quit the program.

10. WAP that prints a table indicating the number of occurrences of each alphabet in the text entered as command line arguments. 11. Write a program that swaps two numbers using pointers. 12. Write a program to generate pay-slip of salaried employee. 13. Write a menu driven program to perform following operations on strings: a) Show address of each character in string b) Concatenate two strings without using strcat function. c) Concatenate two strings using strcat function. d) Compare two strings e) Calculate length of the string (use pointers) f) Convert all lowercase characters to uppercase g) Convert all uppercase characters to lowercase h) Calculate number of vowels i) Reverse the string 14. WAP that encodes English language phrases into a piglatin. To translate each English phrase into a piglatin word, place the first letter of the English word at the end of the word and add the letters ay. Thus the word jump becomes umpjay. Blanks should remain blank. Enable the user to input the sequence of words/phrase Write a function convertToLatinWord that should convert each word into piglatin word. 15. WAP that sorts a list of N numbers using selection sort. 16. WAP that sorts a list of N numbers using insertion sort. 17. WAP that sorts a list of N numbers using bubble sort. 18. Given two ordered arrays of integers, write a program to merge the two-arrays to get an ordered array. 19. WAP that search a given element x in a set of N numbers using Linear search. 20. WAP that search a given element x in a set of N numbers using Binary search. 21. WAP to display Fibonacci series (i)using recursion, (ii) using iteration 22. WAP to calculate Factorial of a number (i)using recursion, (ii) using iteration 23. WAP to calculate GCD of two numbers (i) with recursion (ii) without recursion.

24. Create Matrix class. Write a menu-driven program to perform following Matrix operations (2-D array implementation): a) Sum b) Difference c) Product d) Transpose 25. Create the Person class. Create some objects of this class (by taking information from the user). Inherit the class Person to create two classes Teacher and Student class. Maintain the respective information in the classes and create, display and delete objects of these two classes. (Use Runtime Polymorphism). 26. Create a class Triangle. Include overloaded functions for calculating area. Overload assignment operator and equality operator. 27. Create a class Box containing length, breath and height. Include following methods in it: a) Calculate surface Area b) Calculate Volume c) Increment, Overload ++ operator (both prefix & postfix) d) Decrement, Overload -- operator (both prefix & postfix) e) Overload operator == (to check equality of two boxes), as a friend function f) Overload Assignment operator g) Check if it is a Cube or cuboid Write a program which takes input from the user for length, breath and height to test the above class. 28. Create a structure Student containing fields for Roll No., Name, Class, Year and Total Marks. Create 10 students and store them in a file. 29. Write a program to retrieve the student information from file created in previous question and print it in following format. Roll No. Name Marks

30. Copy the contents of one text file to another file, after removing all whitespaces. 31. Write a function that reverses the elements of an array in place. The function must accept only one pointer value and return void.

32. Write a program that will read 10 integers from user and store them in an array. The program will print the array elements in ascending and descending order. The program must not change the original array or create any other integer arrays. (Use two pointer arrays). Refer the book by Forouzan and Gilberg. 33. Write a function that allocates memory for a single data type passed as parameter. The function uses the new operator and returns a pointer to the allocated memory. The function must catch and handle any exception during allocation. 34. Write a function that handles divide by zero and divide by negative number internally, allowing the user to correct the error, but throws a bad operator exception to the calling function.

You might also like