Assignment 2 CP 21102024 010055pm

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Computer Programming

BSIT- 1-A

Department of Computer Science


Bahria University, Lahore Campus

Assignment: 2
Name: _____________________ Roll No: ___________________
Question Obtained
Evaluation of CLO Marks
Number Marks
CLO2: Exhibit logic building ability using basic programming
1-5 0.5*5
concepts.
Total Marks 2.5

Question 1. Write a C++ program to find the longest contiguous subarray in a 1D array that has
a sum equal to a given target value. If multiple subarrays have the same maximum length, return
the first one.
Question 2. Given a 2D array of integers, write a program to rotate the matrix by 90 degrees
clockwise, in place (without using additional memory for another matrix).
Question 3. Write a program that prints all possible permutations of a given string using
recursion and loops. The program should be able to handle strings of length up to 10.
Question 4. Implement a custom sorting algorithm in C++ using if/else statements and loops
(such as Bubble Sort or Insertion Sort). Enhance the algorithm to handle cases where the array is
already sorted or partially sorted to improve efficiency.
Question 5. Write a program that acts as a simple command-line calculator using a switch
statement. The calculator should support addition, subtraction, multiplication, division, and
modulo operations. Extend the functionality to handle operations with both integers and floating-
point numbers, handling division by zero gracefully.

You might also like