# Mathematics | Homework Helpers

1. Assume that the aIDress of b[0] is 5200 in memory. What output would be produced by the following program (if the output is an aIDress, you need to write out the exact aIDress. For example, the aIDress of b[1] is 5214)?
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int b[] = {3,4,2,5,6,7};
int *xPtr;
xPtr = &b[2];
cout << xPtr << endl;

cout << *xPtr << endl;

Don't use plagiarized sources. Get Your Custom Essay on
Mathematics | Homework Helpers
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!

cout << &b[3] << endl;

cout << b[4] << endl;
*xPtr = 9;
cout << *xPtr << endl;
return 0;
}

2 What is the output of the following program? Explain how the function leftShift shown below works and why we need the variable temp? (Hint: if you dont understand what the program do, please run it and print out what the value of temp when the function is called).

#include <iostream>
using namespace std;
void leftShift(int *);

int main()
{
int a[] = {3, 6, 7, 9, 4, 5, 2, 4, 2, 1};
for (int i = 1; i < 5; i++)
{
cout << Step  << i << :n;
leftShift(a);
}

return 0;
}
void leftShift(int *array)
{
int temp = *array;
for (int i = 0; i < 9; i++)
*(array+i) = *(array+i+1);
*(array+9) = temp;
for (int i = 0; i<10; i++)
cout << *(array+i) <<  ;
cout << endl;
}

3 Given the following definitions and assignments, what do these expressions evaluate to (assume each of the following problems is independent).
int a[] = {2, 4, 0, 3, 5, 9, 12, 6}, n;
int *aPtr = &a[3];

(a) n = *aPtr + 1; n = _____________

(b) n = *(aPtr + 2); n = _____________

(c) n = *(aPtr  2); n = _____________

(d) n = *(++aPtr); n = _____________

(e) n = (*aPtr); n =______________

(f) n = a[++(*aPtr )]; n =______________

4 Point out whether each of the following program segments is valid or invalid. If it is invalid, explain why. Assume the following declarations:
double a = 8.1, b = 2.5;
const double *aPtr = &a;
double * const bPtr = &b;

(a) *aPtr = &b;

(b) *aPtr = 6.5;

(c) aPtr = &b;

(d) aPtr = b;

(e) *bPtr = 3.4;

(f) bPtr = &a;

5 What is the output by the following program segment?
char x[ ] = Today is a nice day ;
char y[50], z[50];
strcpy(y, x);
cout << The string x is:  << x
<< nThe string y is:  << y << endl;
strncpy(z, x, 9);
z[9] = ?;
cout << The string z is:  << z;
strcat(z, y);
cout << nThe string z is:  << z
<< nThe length of z is:  << strlen(z) << endl;

6 Given the class definition:
{
public:
{
result = r;
}
{
return result;
}
{
cout << Your result is << result << endl;
}
private:
int result;
};
Write a main program to perform three tasks: (a) declare an object; (b) assign a value to the data member; (c) output the value.

Programming (hand in C++ code only)

7 Write a function that accepts a pointer to a string as an argument and returns the number of words contained in the string, that is, the function prototype is
int wordCount(char *);
If the string argument is it is a nice day the function should return 5. Demonstrate the function in a program that asks the user to input a string and then passes it to the function. (Hint: you need to use cin.getline() to receive the input string). The sample output is:
Enter a sentence: it is a nice day
The sentence has 5 words.
Dont use strtok function. You can assume that the sentence has no empty spaces at the beginning and at the end.

8 Write a program to prompt user to enter a password. A valid password must have at least 6 characters and must consist of at least one lower character (ASCII code 97-122), one capital character (ASCII code 65-90) and one digital number (ASCII code 49-57). If the user enter a password shorter than 6 characters, or no capital or lower or special character, output the error message and let the user try again. Then let the user enter the password again to verify whether the user has remembered the password. If the two entered passwords are not the same, output error message and try again. If verification is OK, output Your password is: password. Use do-while, break and continue to make your code efficient.
Sample output:
Password must be at least six characters! Try again.
Password must be one lower or capital or digital number! Try again
Two passwords are different. Try again.

9 Define a class called Point which consists two private data x and y with double type and three public member functions: a constructor Point(), void setPoint(double, double), void printPoint(). In the function setPoint, you need to verify if the values of x and y are located between 0 and100. If not set the value to be 0.0. In the printPoint(), print the following message:
(x, y) = (XXX.X, XX.X)
where X is a digit. In your main program, use keyboard to input the values of x and y (one time is OK). Then call setPoint() and printPoint().

&nbsp;

&nbsp;

Pages (550 words)
Approximate price: -

Why Choose Us

Top quality papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

We have hired a team of professional writers experienced in academic and business writing. Most of them are native speakers and PhD holders able to take care of any assignment you need help with.

Free revisions

If you feel that we missed something, send the order for a free revision. You will have 10 days to send the order for revision after you receive the final paper. You can either do it on your own after signing in to your personal account or by contacting our support.

On-time delivery

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & confidential

We use several checkers to make sure that all papers you receive are plagiarism-free. Our editors carefully go through all in-text citations. We also promise full confidentiality in all our services.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.