Define variable ptr to be a pointer to an object of type int


Assignment

Question 1:

Write a program that calculates and prints the product of the even integers from 4 to 20.

Question 2:

Assume that integer array b[5] and integer pointer variable bPtr have been defined. Write a statement to set bPtr equal to the address of the first element in array b. Write a statement using pointer expression to reference the array element b[3].

Question 3:

Provide the definition for each of the following structures:

(a) Structure time containing integers hours, minutes and seconds.
(b) A structure called month that contains character arrays monthName[30], daysOfWeek[20], and an integer variable numberOfDays.

Question 4:

Assume that array int v[5] has been defined and its first element is at location 3000 in memory.

(a) How to initialise a pointer variable vPtrto point to v[0]?

(b) What is the memory address that the pointer vPtrpointsto after executingthe following statement vPtr += 3;?Assume thatan integer is stored in 4 bytes of memory.

Question 5:

Create a structure with members int a, int b and float c. Write a program that demonstrates how a structure variable value1can be assigned to another structure variable value2. Print the value assigned to the structure variable value2.

Question 6:

Write a program to create a structurestudent,which contains name, rolland marksas its data member. Then, the program creates a structure variable s. Then, data name, roll and marksis taken from the user and stored in data members of structure variable s. Finally, the data entered by the user is displayed.

Question 7:

For each of the following, write a statement that performs the indicated task. Assume that integer variables a and b are defined and that a is initialized to 100.

(a) Define the variable ptr to be a pointer to an object of type int.
(b) Assign the address of variable a to pointer variable ptr.
(c) Assign the value of the object pointed to by ptr to variable b.
(d) Print the value of the object pointed to by ptr

Format your assignment according to the following formatting requirements:

1. The answer should be typed, double spaced, using Times New Roman font (size 12), with one-inch margins on all sides.

2. The response also includes a cover page containing the title of the assignment, the student's name, the course title, and the date. The cover page is not included in the required page length.

3. Also include a reference page. The Citations and references should follow APA format. The reference page is not included in the required page length.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Define variable ptr to be a pointer to an object of type int
Reference No:- TGS03009330

Now Priced at $70 (50% Discount)

Recommended (98%)

Rated (4.3/5)