Question

Q1. Write a C++ program that declares three arrays, Markl, Mark2 Result and carries out the following Allow the user to fill mark and mark with 5 integer elements 2. Find the average of each two corresponding elements of the two arrays mark and mark then compare the average with 60 If the average is greater than or equal to 60 then fill the corresponding element of the third array Result with the character (P) Otherwise, file the corresponding element with the character (F) Marka 10 66 90 40 60 30 10 NO 00 P P

Answer

Code : 

 #include<iostream> #define SIZE 5          // Size of the array  using namespace std;  /* This function fills the marks in the array */  void fillmarks(int arr[]){     for (int i = 0; i < SIZE; i++)     {         cout<<"\nEnter "<<i+1<<" : ";         cin>>arr[i];     }      }  /* This function prints all the elelments of the marks array */ void print_array(int arr[]){            cout<<endl;     for (int i = 0; i < SIZE; i++)     {         cout<<arr[i]<<"\t";     } }  /* This function prints all the elelments of the Result array */ void print_array(char res[]){     cout<<endl;     for (int i = 0; i < SIZE; i++)     {         cout<<res[i]<<"\t";     }     }  int main(){     int Mark1[SIZE], Mark2[SIZE];      // int array of Marks1 and Mark2      char Result[SIZE]; // char array for Result array     cout<<"\nMarks 1 : "<<endl;     fillmarks(Mark1);          // Taking input for MArks1 array     cout<<"\n\nMarks 2 : "<<endl;     fillmarks(Mark2); // Taking input for MArks2 array          // Calculating the average for each ef the elements of the arrays Marks1  and Marks2  and then filling the Result array          for (int i = 0; i < SIZE; i++)                      {         double avg = (Mark1[i] + Mark2[i] )/ 2.00;        // Calculating the average for each element         if (avg>=60.00)                                                Result[i] = 'P';                              // If average >= 60  then fill 'P' character in the Result array         else             Result[i] = 'F';                              // If average < 60  then fill 'F' character in the Result array              }     cout<<"\n\nMarks 1 : "<<endl;     print_array(Mark1);                                 // Printing MArks1 array     cout<<"\n\nMarks 2 : "<<endl;     print_array(Mark2);                                 // Printing MArks2 array     cout<<"\n\nResult : "<<endl;     print_array(Result);                                // Printing Result array     return 0; }

Output :

Note :  All the necessary explanation is given in the comment section of the code

  1. Education Tags
  2. :
    • Homework help
    • Study resources
    • Academic assistance
    • Le
    • arning materials
    • Educational support
    • Online tutoring
    • Study guides
    • Exam preparation
    • Homework solutions
    • School assignments
  3. Subject-specific Tags:
    • Mathematics
    • Science
    • English/Language Arts
    • History
    • Geography
    • Computer Science
    • Economics
    • Psychology
    • Sociology
    • Literature
  4. Grade Level Tags:
    • Elementary school
    • Middle school
    • High school
    • College
    • University
    • Graduate level
    • K-12
  5. Study Tools Tags:
    • Practice problems
    • Worksheets
    • Flashcards
    • Quiz questions
    • Lecture notes
    • Textbook solutions
    • Study tips
    • Exam strategies
  6. Online Learning Tags:
    • E-learning
    • Distance education
    • Virtual classroom
    • Online courses
    • Digital learning
    • Remote learning
    • Internet resources
  7. Additional Tags:
    • Free answers
    • Homework assistance
    • Academic resources
    • Study community
    • Student help
    • Assignment help
    • Problem-solving
    • Tutoring services
    • Peer collaboration
  8. Chegg Unlock
    • Chegg free questions
    • Chegg Answers
    • Bartleby Answers
    • CourseHero unlock
  9. Mail us or contact us if you need any help related to your homework and assignments. Also, for the projects as well.

Leave a Reply

Discover more from Technical Gamer

Subscribe now to keep reading and get access to the full archive.

Continue reading