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

Assignment 2

This document provides instructions for an assignment on programming fundamentals. Students are asked to submit 8 required programs that perform operations like swapping array elements, rotating arrays, sorting arrays in ascending and descending order using different sort algorithms. It also lists 6 optional programs involving operations like deleting and inserting array elements, searching arrays, and combining two sorted arrays. Students are advised that plagiarized work or code written using AI tools will receive zero marks.

Uploaded by

尸 工 长 丹
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Assignment 2

This document provides instructions for an assignment on programming fundamentals. Students are asked to submit 8 required programs that perform operations like swapping array elements, rotating arrays, sorting arrays in ascending and descending order using different sort algorithms. It also lists 6 optional programs involving operations like deleting and inserting array elements, searching arrays, and combining two sorted arrays. Students are advised that plagiarized work or code written using AI tools will receive zero marks.

Uploaded by

尸 工 长 丹
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

COMSATS University Islamabad

Sahiwal Campus
Department of computer science
Assignment # 2

Subject: Programming Fundamentals Couse code: CSC103 Due date: 25/10/2023


Instructor: M. Arslan Sarwar Class: SP23-BSE-A Total marks: 30

Note: You need to develop and run these programs of your own. I may conduct viva/quiz to
verify if programs are actually written by you. Failure to show understanding of code, copied
assignment and code written using AI tools will yield 0 marks.

You need to submit the assignment as 2 files, one zip file containing .cpp code files, and a word
file containing screenshot of code and output of code. Screenshots should be of whole screen
and should not be cropped. You will email your assignment at:
[email protected].

1. Write a program that swap elements of 2 arrays of same size.


2. Write a program that rotate elements of array by moving each element to
next location and moving last to first. For example, if array is {2,5,7,3,10} it
will be {10,2,5,7,3} after rotation.
3. Write a program in C++ that input an array. Considering array is given
sorted in ascending order, you need to convert that array to sorted in
descending order without using any other array.
4. Write a program in C++ to count and print all unique elements in an array.
5. Write a program that find common elements of 2 arrays.
6. Write a program in C++ to sort elements of array in ascending order using
Bubble sort.
7. Write a program in C++ to sort elements of array in ascending order using
Selection sort.
8. Write a program in C++ to sort elements of array in ascending order using
Insertion sort.
Following programs are optional

1. Write a program in C++ that input an array of size n, an index between 0


to n-1 and deletes the element from given index such that array size
would be n-1 after deletion.
2. Write a program in C++ that input an array of size n, a value x, then search
and delete the element x from given array at all occurrences. Array size
must be n-m after deletion in case x occurs m times.
3. Write a program in C++ that input an array of size n, a value x, and inserts
x into given array. Considering user will always enter array sorted in
ascending order, so the array must remain sorted after insertion. Array
size would be n+1 after insertion.
4. Write a program in C++ that input two arrays a, b and search if b array
exist in a array or not. If exist, it must also tell the index from which it
starts in a array. Consider that size of b array will always be less or equal
to a array.
5. Write a program in C++ that input two arrays a, b. Considering that a and
b array are given in sorted form in ascending order, you need to combine
them in third array c such that c is also sorted in ascending. If size of a
array is n, size of b is m, size of c will be n+m.
6. Write a program in C++ to search elements from array given in ascending
order using binary search.

You might also like