PDS Assignment 4
PDS Assignment 4
1. Given three numbers A, B, and C you have to write a function named calcSum( )
which takes these 3 numbers as arguments and returns their sum.
2. Write a program to find the factorial of a given number by using a user-defined
function.
3. Write a C++ program for swap two numbers using functions.(call by value)
4. Write a C++ program for swap two numbers using functions.(call by reference)
5. Write a C++ program to Perform All Arithmetic Operations Using Functions.
6. Write a menu-driven program that allows a user to enter five numbers and then
choose between finding the smallest, largest, sum, or average. The menu and all the
choices are to be functions. Use a switch statement to determine what action to take.
Provide an error message if an invalid choice is entered.
7. Given 3-angles as parameters, Write a function to check whether they form a triangle
or not (A+B+C =180). If yes check whether a triangle is scalene, equilateral, isosceles,
or right-angled triangle.
8. Write a function to take a floating point number as input and return the same number
rounded to k decimal places. Do not use any system-defined functions. If the input is
17.24578, and k = 2, the output is 17.25, and 345.2034 is rounded as 345.20.
9. Use functions to write a program to implement an integer calculator with functions
add, subtract, multiply, quotient, modulus, and exponent.
10. Write a program to read the principal amount, rate of interest, and time in years and
calculate simple interest and compound interest compounded every k month using
functions.
11. Write a program to validate inputs and determine the elder person when the DOB of
two persons is given as date, month, and year.
12. Develop functional decomposition and write a C++ program to print the calendar
of a year, given the day of the week of January first of the year.
13. Given the length and breadth of a rectangle, write a program to find whether the
area of the rectangle is greater than its perimeter. For example, the area of the
rectangle with length =5 and breadth = 4 is greater than its perimeter.
14. Given three points (x1, y1), (x2, y2), and (x3, y3), write a program to check if all
the three points fall on one straight line.
15. A five-digit number is entered through the keyboard. Write a program to obtain
the reversed number and to determine whether the original and reversed
numbers are equal or not.
16. If the cost price and selling price of an item are input through the keyboard, write
a program to determine whether the seller has made a profit or incurred a loss.
Also, determine how much profit he made or loss he incurred.
17. If a five-digit number is input through the keyboard, write a program to print a
new number by adding one to each of its digits. For example, if the number that is
input is 12391 then the output should be displayed as 23402.