Assignment1 OOP
Assignment1 OOP
Assignment1 OOP
Submission: You are required to submit solution of all questions as a single word file through MS-
Teams. Name your file as “Reg No-Student Name-ProgramName”.
Deadline: Deadline to submit the assignment is 5th April 11:55 PM. No submission will be considered
for grading outside the MS-Teams or after 5th April 11:55 PM. Correct and timely submission of the
assignment is the responsibility of the student; hence no relaxation will be given to anyone.
Plagiarism: -50% marks in the assignment if any part of the assignment is found plagiarized.
Program 1:
Write a program to compute the sum and the sum of the squares of all data elements in the following
array arr[ ]={1,2,3,4,5}
Program 2:
Write a Program that calculates the total price of four items {2.0, 5.0, 1.0, 2.0} after entering the
quantity for each item such as:
Program 3:
(Conversion from kilograms to pounds) Write a program that displays the following table (note that 1
1 Kilogram is 2.2 pounds):
Kilograms Pounds
1 2.2
3 6.6
…
197 433.4
199 437.8
Program 4:
Suppose that the tuition for a university is PKR. 90,000 this year and increases 10% every year. In one
year, the tuition will be PKR. 99,000. Write a program that computes the tuition in ten years and the
total cost of four years’ worth of tuition after the tenth year.
Program 5:
Write an if-else statement to compute the amount of shipping due on an online sale. If the cost of the
purchase is less than $20, the shipping cost is $5.99. If the cost of the purchase over $20 and at most
$65, the shipping cost is $10.99. If the cost of the purchase is over $65, the shipping cost is $15.99.
Program 6:
Write a program called Strings2 that requires the user to type a long sentence. The program displays
the longest word in the sentence.
Sample Run:
Enter Sentence: The longest I have ever worked in my life-time was eight days!
Longest word is: life-time
Program 7:
Write a C++ program to swap two integers using pointers. Your program should take two integer
inputs from the user, swap their values using pointers, and then print the swapped values. You should
implement the swapping function using pointers, and not using any other temporary variable.
Program 8:
Program 9:
Write a recursive function in C++ to compute the nth Fibonacci number, where the nth Fibonacci
number is defined as the sum of the (n-1)th and (n-2)th Fibonacci numbers, with the first two Fibonacci
numbers being 0 and 1. Your function should take an integer n as input and return the nth Fibonacci
number.
Program 10:
COMP112 – Semester Project’s Requirements (Due date for only below highlighted requirements is:
05/04/2023, 11:55PM through this assignment submission)
o E.g., if you heard a beneficial YouTube, you can post the link on MS-Teams.
After you form the group and after you have a clear picture of your project idea, please come to me
to give you extra tips and recommendations.
**** “University Education is not the learning of facts, but the training of minds to think .” Albert Einstein ****