EECE7205: Fundamentals of Computer Engineering‐ Homework 1 solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

Problem 1 (20 Points) Write  a  C++  program  to  implement  and  test  two  functions: SwapP  and SwapR.  SwapP  swaps  the  values  of  two  integer  variables  using  pass‐by‐pointer.  SwapR swaps the values of two integer variables using pass‐by‐reference.  Problem 2 (20 Points) Replace the question marks in the following C++ program with C++ code to swap  the p1 and p2 pointers to point to each other’s values.  # include using namespace std; int main () {   int x = 1, y = 9;   int *p1, *p2;   p1 = &x;   p2 = &y;       ??????????     cout << *p1 << ” and ” << *p2 << endl; // Prints “9 and 1” return 0; } Problem 3 (60 Points) Write a C++ program that starts by asking a teacher  for  the size of his class  (the  number of students). Then the program asks the teacher to enter for each student  his/her name along with his/her grade in an exam. All grades are integers that have  to be in the range from 0 to 100 (inclusive). Store the names in an array of strings  and the grades in another array of integers. Use dynamic memory to create both  arrays.   Define a function that implements the sorting algorithm INSERTION‐SORT(A,n) as explained in  class.  Call  this  function  to  sort  the above arrays in a  descending  order of the students’ grades in the exam.   Your program will display the sorted list of students’ names along with their grades.