[Solved] 2 Pointer Arithmetic Write Printstring Function Prints String Char Char Using Pointer Arit Q37167141
2. Pointer arithmetic: a) Write a printString function thatprints a string (char-by-char) using pointer arithmetics anddereferencing. b) Write a function “void computeMinMax(doublearr[], int length, double * min, double * max)” that finds theminimum and the maximum values in an array and stores the result inmin and max. You are only allowed to use a single for loop in thefunction (no while loops). Find both the min and the max using thesame for loop. Remember to initialize min and max to “good”values.
The function prototypes and a sample main are provided below:
void printString(char str[]);
void computeMinMax(double arr[],int length,double * min,double *max);
void main(){ char s[] = “I like homework”;
printString(s); printf(“n”);
double arr[] = {1,-1.1,40,50,3,3,2,3};
double min,max;
computeMinMax(arr,8,&min,&max);
printf(“min: %lf max: %lfn”,min,max);
}
This is what i have so far:
#include <stdio.h>
#include <stdlib.h>
void printString();
void main(){
char s[] = “I like homework”;
printString(s);
printf(“n”);
}
void printString()
{
char str[]=”Hello There”;
char *ptr = str;
while(*ptr != NULL) {
// print original char,
printf(“%c n”, *(ptr++));
}
}
Expert Answer
Answer to 2. Pointer arithmetic: a) Write a printString function that prints a string (char-by-char) using pointer arithmetics and… . . .
OR

