You are on page 1of 4

# Chandigarh University, Gharuan

Paradigms of Computer Programming and
Subject Code: CSP L T P C
C++Lab
157
Total Contact Hours : 30 Hours
0 0 4 2
Common to all Branches of First Year
Marks-100
Internal-60 External-40
Course Objectives
 To understand the concept of the various Programming Paradigms
 To apply different programming languages for modeling real world problems.
Unit Course Outcomes
Understand the various paradigms of computer programming
Identify the strengths and weaknesses of different programming paradigms
I-III Students will demonstrate basic experimental skills for differentiating between
object oriented and procedural programming paradigms and the advantages of
object oriented programs.

UNIT-I
Program based on basics datatypes and operator in C++.
i. Assuming there are 7.481 gallons in a cubic foot, write a program that asks the user to enter
a number of gallons, and then displays the equivalent in cubic feet.
ii. Convert temperature from degrees Celsius to degrees Fahrenheit by multiplying by 9/5 and
adding 32. Write a program that allows the user to enter a floating-point number
representing degrees Celsius, and then displays the corresponding degrees Fahrenheit.
Program based on conditional constructs.
i. The normal speed of a vehicle is less than 65kmph. If entered speed is less than 65kmph you
can print within speed limit otherwise over speed limit.
ii. Create the equivalent of a four-function calculator. The program should request the user to
enter a number, an operator, and another number. (Use floating point.) It should then carry
out the specified arithmetical operation: adding, subtracting, multiplying, or dividing the
two numbers. Use a switch statement to select the operation. Finally, display the result.
When it finishes the calculation, the program should ask if the user wants to do another
calculation. The response can be ‘y’ or ‘n’. Some sample interaction with the program might
look like this:
Program based on looping.
i. Write a program that calculates how much money you’ll end up with if you invest an
amount of money at a fixed interest rate, compounded yearly. Have the user furnish the

(This member should apply to the class as a whole. It should create an array of type employee. as each object is created. and then generates the table. Write a program that allows the user to enter the number. iv. That is. ii. and then invite the user to input data for up to 100 employees.) So the number of possible arrangements of six guests in four chairs is 6*5*4*3. (The last two will have to stand. but your table seats only four. Assume the name has no embedded blanks. iii. type float). Include a member function called getdata() to get data from the user for insertion into the object.43 rupees. the number of years. it should print out the data for all the employees. Suppose you give a dinner party for six guests. And also calculate total compensation. you will have 5124. Assume you want to generate a table of multiples of any given number. Finally.5 At the end of 10 years. the second 2. Write a program that calculates the number of possible arrangements for any number of guests and any number of chairs. To do this. Create a class that includes a data member that holds a “serial number” for each object created from the class. Program to generate the Fibonacci series up to user specified limit. What keyword specifies this?) Then. initial amount. and so on. store it in three variables of type struct employee. ii. you’ll need another data member that records a count of how many objects have been created so far. the first object created will be numbered 1. iii. i. and the yearly interest rate in percent. Write a main() program to exercise this class. Any of the remaining four can sit in the third chair. Create a structure called employee that contains two members: an employee number (type int) and the employee’s compensation (in dollars. formatting it into 10 columns and 20 lines. In how many ways can four of the six guests arrange themselves at the table? Any of the six guests can sit in the first chair. Program based on the concept of structure and class. and any of the remaining three can sit in the fourth chair. Create a class called employee that contains a name (an object of class string) and an employee number (type long). Some interaction with the program might look like this: Enter initial amount: 3000 Enter number of years: 10 Enter interest rate (percent per year): 5. and another function called putdata() to display the data. Ask the user to fill in this data for three employees. its constructor can examine this count member variable to determine the appropriate serial . not to individual objects. Any of the remaining five can sit in the second chair. and then display the information for each employee. which is 360.