C++ only :
Use an integer pointer returning function which would determine the sum of square of each of two integer pointer variables used as argument of the function. Call the function in the main() using pointer variables and dynamic allocation
Question 4: Print both the strings using string double-pointer only in the main()
void print(string ** s){
**s = "University of Oregon";
cout<< **s <<endl;
}
void print(string *x){
*x = "Portland";
cout<<*x<<endl;
}
#include <iostream>
using namespace std;
int *square(int *a, int *b) {
int *c;
*c = (*a * *a + *b * *b);
return c;
}
int main() {
int *a = new int;
int *b = new int;
*a = 12;
*b = 5;
cout << *square(a, b);
}
NOTE: As per Chegg policy I am allowed to answer specific number of questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.
C++ only : Use an integer pointer returning function which would determine the sum of square...
Use only C++ for all function Introduce a call-by-value function that computes the volume of a box. Hint: Length, width, and height of a box is needed. Introduce a call-by-reference function with void output. that computes the square of an integer. Please double check the value of the function input before and after function call. Introduce a call-by-pointer function with void output. that computes the square of an integer. Please double check the value of the function input before and...
Using C++ Write two `void` functions. These functions each take two integer parameters. The functions accomplish the following tasks. The first function prints out the numbers from the first argument up to and including the number passed as the second argument counting by the first argument (i.e. if the arguments are 2 and 10, the information below was given: #include <iostream> using namespace std; // function definitions// // main program int main() { int firstNumber,secondNumber; char countType, doAgain; // we will do this...
81. The following function call doesn’t agree with its prototype: cout << BoxVolume( 10, 5 ); int BoxVolume(int length = {1}, int width = {1}, int height = {1}); T__ F__ 82. The following function is implemented to swap in memory the argument-values passed to it: void swap(int a, int b) { int temp; temp = a; a = b; b = temp; ...
C ++ 1. Write down the missing code according to the comments. #include <cstdlib> #include <iostream> using namespace std; void fun1(int radius) { /* dynamic memory management */ double * dmptr; double circumference; /* add the code below to: - allocate a memory location for a double and nameless variable in heap and assign its address to the pointer - assign 3.14 to the variable in heap via the pointer....
MUST USE C++ PLEASE READ THE QUESTION CAREFULLY!! ADD COMMENTS/EXPLAIN Question 1: Template Function with Pointer Arguments Design and implement a template function, called swapt(T *p1, T *p2), which takes two parameters with the same generic data type. The function swaps the values of these two parameters. Test this function in the following main( ) : int main( ) { int x = 30, y = 40; swapt(&x, &y); cout << “x = “ << x...
IN C++ Given ProblemSolution class. Use a pointer to object of “ProblemSolution” class to invoke the “CalculateSum” and “Print” methods of “ProblemSolution”. Write a function: void Solution(int N1, int N2) that accepts two integers N1 and N2. The function should instantiate “ProblemSolution” object with N1 and N2 values and call “CalculateSum” and “Print” method by creating a pointer to the object of “ProblemSolution”. Input 12 5 Output 17 Assume that, N1, N2 and sum are integers within...
Declare and define TtuStudentNode in TtuStudentNode.h and TtuStudentNode.cpp file. TtuStudentNode has its unique string variable "studentEmail" which contains email address. TtuStudentNode has its unique function member GetEmail() which returns the string variable "studentEmail". TtuStudentNode has its overriding "PrintContactNode()" which has the following definition. void TtuStudentNode::PrintContactNode() { cout << "Name: " << this->contactName << endl; cout << "Phone number: " << this->contactPhoneNum << endl; cout << "Email : " << this->studentEmail << endl; return; } ContactNode.h needs to have the function...
Using a programming language of your choice, write a complete and fully functional program that uses reference and pointer types to swap two integer numbers. The two numbers are read in separately by the program’s user. Use a proper prompt for each number read in. a. Use one function that uses formal parameter reference type to swap the two numbers b. Use another function that uses formal parameter pointer type to swap the two numbers. c. In the main or...
SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL
CODE
PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT
NEEDED!!!
mystring.h:
//File: mystring1.h
// ================
// Interface file for user-defined String class.
#ifndef _MYSTRING_H
#define _MYSTRING_H
#include<iostream>
#include <cstring> // for strlen(), etc.
using namespace std;
#define MAX_STR_LENGTH 200
class String {
public:
String();
String(const char s[]); // a conversion constructor
void append(const String &str);
// Relational operators
bool operator ==(const String &str) const;
bool operator !=(const String &str) const;
bool operator >(const...
C++ Write a recursive function that reverses the given input string. No loops allowed, only use recursive functions. Do not add more or change the parameters to the original function. Do not change the main program. #include <iostream> #include <string> using namespace std; //Write a recursive function 'void reverse(string &str)' that reverses the given input string. void reverse(string &str) { /*Code needed*/ } int main() { string name = "sherry"; reverse(name); cout << name << endl; //should...