Group Assignment Fundamental Programming
Group Assignment Fundamental Programming
Group members
Abdirahman jamac 1406152
Abdikalik faysal 1406158
Rufai sharif 1406145
Sirika wakgari 1406162
Abdishakur abdi 1406118
Question 1
#include <iostream>
#include <vector>
std::pair<std::vector<int>, std::vector<int>> separatePositiveNegative(const std::vector<int>&
arr) {
std::vector<int> positive;
std::vector<int> negative;
int main() {
int size;
std::cout << "Enter the size of the array: ";
std::cin >> size;
std::vector<int> nums(size);
return 0;
}
Question 2:
#include <iostream>
#include <algorithm>
int main() {
int n;
int arr[MAX_SIZE];
std::cout << "Enter the number of integers (1 - " << MAX_SIZE << "): ";
std::cin >> n;
inputArray(n, arr);
int num;
std::cout << "Enter a number to find: ";
std::cin >> num;
bool found = findNumber(n, arr, num);
std::cout << "Number " << num << (found ? " is" : " is not") << " found in the array." <<
std::endl;
sortArray(n, arr);
outputArray(n, arr);
outputReverse(n, arr);
return 0;
Question 3
#include <iostream>
int main() {
int marks[MAX_COURSES];
int numCourses = MAX_COURSES;
fillMark(marks, numCourses);
char choice;
do {
cout << "\nMenu:\n";
cout << "(D)isplay, (R)eplace, Re(F)ill, or (Q)uit?\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 'D':
case 'd':
displayMark(marks, numCourses);
break;
case 'R':
case 'r':
replaceMark(marks, numCourses);
break;
case 'F':
case 'f':
fillMark(marks, numCourses);
break;
case 'Q':
case 'q':
cout << "Exiting the program...";
break;
default:
cout << "Invalid choice! Please try again.\n";
break;
}
} while (choice != 'Q' && choice != 'q');
return 0;
}
Question 4
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int arr[MAX_SIZE];
int size, replacement, numToSearch;
char option;
fillArray(arr, size);
do {
cout << "(D)isplay, (R)eplace, Re(F)ill, or (Q)uit? ";
cin >> option;
option = tolower(option);
switch (option) {
case 'd':
displayArray(arr, size);
break;
case 'r':
cout << "Enter a number to search for: ";
cin >> numToSearch;
cout << "Enter replacement: ";
cin >> replacement;
return 0;
}