Develop the following functions and call them from the main program:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
float avgSalary(int salaries[],int size){
int i,sum=0;
for(i=0;i<size;i++){
sum+=salaries[i];
}
return ((float)sum)/size;
}
void printSalary(int salaries[],int size){
int i;
for(i=0;i<size;i++){
if(i%10 == 0)
printf("\n");
printf("%d , ",salaries[i]);
}
}
int maxSalary(int salaries[],int size){
int i,max=salaries[0];
for(i=0;i<size;i++){
if(salaries[i]>max)
max=salaries[i];
}
return max;
}
int searchSalary(int salaries[],int size,int value){
int i,count=0;
for(i=0;i<size;i++){
if(salaries[i]==value)
count++;
}
return count;
}
void sortSalary(int salaries[],int size){
int i,j;
for(i=0;i<size;i++){
for(j=0;j<size-i-1;j++){
if(salaries[j]>salaries[j+1]){
int temp = salaries[j+1];
salaries[j+1] = salaries[j];
salaries[j]=temp;
}
}
}
}
int main()
{
srand(time(0)); //setting up unique seed
int salaries[100],i; //a : define array
for(i=0;i<100;i++) //b : initialize with 0
salaries[i]=0;
for(i=0;i<100;i++){ //c : fill up array using rand ,
srand
salaries[i] = 350 + (rand()%(3000-350+1));
}
printf("\n\n==============================Function
calls====================================\n\n");
printSalary(salaries,100);
printf("\n\nAverage salary is : %f",avgSalary(salaries,100));
printf("\n\nMaximum salary is : %d",maxSalary(salaries,100));
printf("\n\nSalary of amount 360 occurs %d
times",searchSalary(salaries,100,360));
sortSalary(salaries,100);
printf("\n\nSorted salary : ");
printSalary(salaries,100);
return 0;
}
![#include<stdio.h> #include<stdlib.h> #include<time.h> float avgSalary(int salaries [], int size) { int i, sum=0; for(i=0;i<si](http://img.homeworklib.com/questions/01486570-940e-11eb-8a4d-b9c102eac1af.png?x-oss-process=image/resize,w_560)
![int searchSalary(int salaries [], int size, int value) { int i, count=0; for(i=0;i<size; i++) { if salaries[i]==value) count+](http://img.homeworklib.com/questions/01be56d0-940e-11eb-b1d8-0de8cf933968.png?x-oss-process=image/resize,w_560)
Write a C program that deal with employees’ salaries in a company, as follows: Define an...
I need a c++ code please. 32. Program. Write a program that creates an integer constant called SIZE and initialize to the size of the array you will be creating. Use this constant throughout your functions you will implement for the next parts and your main program. Also, in your main program create an integer array called numbers and initialize it with the following values (Please see demo program below): 68, 100, 43, 58, 76, 72, 46, 55, 92, 94,...
Hello, I need a c program called int* create_random_array(int n) that returns a random array of size an. Alternatively, you can initialize a pointer to an array (called Rand) and write a function called void(create_array(int * Rand, int n) which assigns an array of size n to Rand. Note: Plese utilize rand(fi) and srand() from stdlib.h for this code
C++ Problems: 1. Write a program that reads in an array of user given size n and then it reads several increment values terminated by 0. The program calls each time a function incarray() that accepts an array A, its size S and an increment value inc and updates yje array by incrementing all its values by the passed value of inc. The program prints out the array after each update. 2. write a program that reads in a n...
In C++: Write a C++ function binsearch that carries out the binary search algorithm on a sorted array of integers. Your function takes as parameters an array of integers (sorted in increasing order), the size of the array, and a target integer to search for. The function returns the index of the target in the array, and returns -1 if the target is not in the array. Using the code below, add your binsearch function to this C++ program. (Do...
Write a C++ function binsearch that carries out the binary search algorithm on a sorted array of integers. Your function takes as parameters an array of integers (sorted in increasing order), the size of the array, and a target integer to search for. The function returns the index of the target in the array, and returns -1 if the target is not in the array. The file main1.txt on the webpage contains code that generates a specific array of integers...
create a file homework_part_1.c a) Implement the function initialize_array that receives two parameters: an array of integers and the array size. Use a for loop and an if statement to put 0s in the odd positions of the array and 5s in the even positions. You must use pointers to work with the array. Hint: review pointers as parameters. b) Implement the function print_array that receives as parameters an array of integers and the array size. Use a for statements...
7eatng that function Write a C++ program that does the following: Fill an array of 123 elements using srand) and rand) with random numbers between 150 and 667. Fill an array of 123 elements with random numbers between 150 and 667. Using a loop. Fill an array of 123 elements with random numbers between 150 and 667. Using a for loop Use a void function to fill an array of 123 elements with random numbers between 150 and 667, Possible...
Write a program using C in Microsoft visual studios. Write a function that receives an array of integers and the array length and prints one integer per line (Hint: Use \n for a line break). Left align all of the integers and use a field width of 10. Populate an array of 10 elements from the user and pass the array and its length to the function.
write program in c # to do the following : Insert 10 student scores and store them in an array Create a function that prints array elements Create a function that returns the highest mark Create a function that calculates the average score Create a function that calculates the pass rate, knowing that the pass mark is 60
Write a C program to do the following: 1. Write a C function named find that receives a one-dimensional array of type character named arr and its size of type integer. After that, the function must select a random index from the array. The function must find if the character stored in the randomly selected index comes before all the characters to its left alphabetically. Finally, the function prints to the screen the element if the element meets the condition...