Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

INSTRUCTIONS In this assignment, we will be writing a series of functions that u

ID: 3530349 • Letter: I

Question

INSTRUCTIONS

In this assignment, we will be writing a series of functions that use array and pointer notation for passing arguments.In your main() function, declare an array of 20 integers and a string containing a hard-coded sentence (in a char[]).Try to make your sentence at least 20 characters.Use #define statements to state the size of both arrays upfront.Write the following functions and demonstrate their use in main().

Function #1

Signature:int ReturnLargest(int[])

Description: This function takes in an array of numbers and returns the value of the largest number in the array.When accessing the array, you must use array notation in your logic ([])

Function #2

Signature:int ReturnSmallest(int*)

Description: This function takes in an array of numbers and returns the value of the smallest number in the array.When accessing the array, you must use pointer notation in your logic (*)

Function #3

Signature:int ToUpperCase(char*)

Description: This function takes in a string and converts all lower-case letters to upper-case letters.The function then returns an integer reflecting the number of characters that were changed in the string.When accessing the array, you may use any notation that you desire.

Explanation / Answer

#include<cstdlib>

#include <iostream>


using namespace std;

#define ARR_SIZE 20

#define CHAR_SIZE 21

int ReturnLargest(int[]);

int ReturnSmallest(int*);

int ToUpperCase(char*);

int main(){


int arr[] = {2,1,23,45,11,3,4,5,6,7,8,1,2,3,4,5,100,2,31,20};

char str[] = "macHiNe CoDe Assembly";

cout<<ReturnLargest(arr)<<endl;

cout<<ReturnSmallest(arr)<<endl;

cout<<ToUpperCase(str)<<endl;


return 0;

}

int ReturnLargest(int a[]){


int max = a[0];

int i;

for(i=1;i<ARR_SIZE;i++){

if(a[i]>max)

max = a[i];

}

return max;

}

int ReturnSmallest(int* a){

int min = *(a);

int i;

for(i=1;i<ARR_SIZE;i++){

if(*(a + i) < min)

min = *(a+i);

}

return min;


}

int ToUpperCase(char* str){


int i;

int count = 0;

for(i=0;i<CHAR_SIZE;i++){

if(str[i]>=97&&str[i]<=122){

str[i]=str[i]-32;

count++;

}


}

return count;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote