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

Define the class \'Poly\' that contains the following three data items (private

ID: 3805567 • Letter: D

Question

Define the class 'Poly' that contains the following three data items (private data): An array of 100 locations of type integer call it a. Two variable of type integer call them n and x. The class 'Poly' also contains two member functions: setn sets the value of n (passed as a parameter) and returns nothing. SetCoefficients sets a_0, a_1, a_2, ..., a_n, by asking the user to enter them. This function has no parameter and returns nothing; Note that you just need to write the definition of the class. Do not write body of the functions. Write a function called AddStrings(Str1,Str2) that joins two null terminated ('C') strings and returns the address of the concatenated string. The caller has two null terminated strings ('C' strings) which are held in individual dynamically allocated memory blocks. The function accepts the addresses of these memory blocks as input parameters. The function is required to create a new memory block that is large enough to hold the concatenated string and return the address of the new memory block holding the concatenated string. With the use of an example for each, answer the following questions on C++ header files: 1- What is the purpose of a C++ header file? Your explanation should include reference to typical header file content

Explanation / Answer

Answer 9:

PROGRAM CODE:

#include <iostream>
using namespace std;

class Poly
{
   int a[100];
   int n,x;
   public:
   void setn(int n);
   void SetCoefficients();
};

Answer 10:

#include <stdio.h>
#include <malloc.h>
#include <string.h>
using namespace std;

char* AddStrings(char *Str1, char *Str2)
{
   int len = strlen(Str1) + strlen(Str2);
   char *newString = (char *)malloc(len * sizeof(char));
   strcpy(newString, Str1);
   strcat(newString, Str2);
   &newString;
}

int main() {
   printf("%p", AddStrings("hello", "world"));
   return 0;
}

OUTPUT:

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