It works but the output is broken :)
This commit is contained in:
48
Semester 3/Assignments/functions/arrays.cpp
Normal file
48
Semester 3/Assignments/functions/arrays.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/cppFiles/class.cc to edit this template
|
||||
*/
|
||||
|
||||
/*
|
||||
* File: arrays.cpp
|
||||
* Author: caleb
|
||||
*
|
||||
* Created on March 1, 2024, 11:11 AM
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
#include "arrays.h"
|
||||
|
||||
void initializeArray (int arr[], const int size) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
arr[i] = i+10;
|
||||
}
|
||||
}
|
||||
|
||||
void printArray(int arr[], const int size) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
cout << arr[i] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int& returnAddressOfFirstElementOfArray (int arr[3]) {
|
||||
return arr[0];
|
||||
}
|
||||
|
||||
int findMaxAndMin(int arr[2][3], int & min) {
|
||||
int max = arr[0][0];
|
||||
min = arr[0][0];
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
if (min > arr[i][j]) {
|
||||
min = arr[i][j];
|
||||
}
|
||||
if (max < arr[i][j]) {
|
||||
max = arr[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
Reference in New Issue
Block a user