Question
hi, just wondering if anyone can check my answer here and let me know if it's correct or not? thank you! Create an array of
hi, just wondering if anyone can check my answer here and let me know if it's correct or not? thank you!
Create an array of type float with 10 elements. Write a modular program that does the following: Read values into the array representing salaries. Give everyone a 20% pay rise! Display the new salaries. Find the largest salary and display this, along with the index where it occurs.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include
#include
void readSalaries(float salaries[]);
void displaySalaries(float salaries[]);
void riseSalaries(float salaries[]);
void largestValue(float salaries[]);
int main(){
float salaries[10];
readSalaries(salaries);
riseSalaries(salaries);
displaySalaries(salaries);
largestValue(salaries);
getch();
}
void readSalaries(float salaries[]){
for(int i=0; i<10; i++){
printf("Enter Values : ");
scanf("%f",&salaries[i]);
}
}
void riseSalaries(float salaries[]){
for(int i=0; i<10; i++){
salaries[i] = salaries[i] + (salaries[i]*0.20);
}
}
void displaySalaries(float salaries[]){
for(int i=0; i<10; i++){
printf("Salary : %f ",salaries[i]);
}
}
void largestValue(float salaries[]){
float max = 0;
int index = 0;
for(int i=0; i<10; i++){
if(max < salaries[i]){
max = salaries[i];
index = i;
}
}
printf(" Largest Value : %f found on %d index ",max,index);
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started