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

Description This programming assignment will have you write two programs. The fi

ID: 2249679 • Letter: D

Question

Description This programming assignment will have you write two programs. The first program will be a modification of Assignment 3. Just as in Assignment 3, the user will input up to 20 numbers, and these numbers will be stored in an array. Write functions called arrmin, arrmax, and arraver that will take as input and array, and return the minimum value of the array, the maximum value of the array, and the average of the array respectively. After the user enters the values of the array, use the functions to compute the min, max, and average of the array values and print them out. 1. 2. (Prata Chap. 11, Problem 10). Write a function that takes a string as an argument and removes the spaces from the string. Test it in a program that uses a loop to read lines until you enter an empty line. The program should apply the function to each input string and display the result.

Explanation / Answer

1 .

#include<stdio.h>

#include<string.h>

#include<conio.h>

int arrmin(int arr[]);

int arrmax(int arr[]);

int arrmin(int arr[])

{

int i,min = 65535;

for(i=0;i<20;i++)

{

if(arr[i]<min)

{

min = arr[i];

}

}

return min;

}

int arrmax(int arr[])

{

int i,max = -65535;

for(i=0;i<20;i++)

{

if(arr[i]>max)

{

max = arr[i];

}

}

return max;

}

int arrver(int arr[])

{

int i,aver = 0,sum=0;

for(i=0;i<20;i++)

{

sum = sum+arr[i];

}

aver = sum/20;

return aver;

}

main()

{

int arr[20],i,minvalue,maxvalue,average;

printf("enter array elements");

for(i=0;i<20;i++)

{

scanf("%d ",&arr[i]);

}

minvalue = arrmin(arr);

printf("min value is: %d ",minvalue);

  

maxvalue = arrmax(arr);

printf("max value is: %d ",maxvalue);

  

average = arrver(arr);

printf("average is: %d ",average);

  

}

2.

#include<stdio.h>

#include<string.h>

#include<conio.h>

main()

{

char str[100],str2[100];

int i=0,count = 0;

gets(str); //entered string is stored in str along sith spaces

while(str[i] != '')

{

if(str[i] != ' ')

str2[count++] = str[i++];

}

str2[count] = '';

puts(str2);

}