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

In a C++ program you need to store the identification numbers of 10 employees (a

ID: 3843466 • Letter: I

Question

In a C++ program you need to store the identification numbers of 10 employees (as ints) and their weekly gross pay (as doubles).1) Write the statements (not the complete program) that define two arrays named id and pay that may be used to store the 10 employee identification numbers and gross pay amounts. 2) Assume the employee identification numbers and gross pay amounts have already been stored in the above two arrays. Write a loop (not the complete program) that outputs each employee's identification number and gross pay from the two arrays.

Explanation / Answer

a) The below statements define two arrays to store the data
   int id[10];
   double pay[10];

//Input can be taken as follows (extra information than asked in the question)

//Take input of id and pay for each employee
   for(int i=0;i<10;i++)
   {
   cin>>id[i]>>pay[i];
   }

b) The id and gross pay can be printed using 'cout' as follows

for(int i=0;i<10;i++)
   {
   cout<<id[i]<< " "<<pay[i];
   }

//Also, it can be printed using format specifiers as follows-

for(int i=0; i<10; i++)

{

printf("%d %f", id[i], pay[i]);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote