Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is the purpose of PHP dynamic extension *.dll files?

Answered: 1 week ago