Question
in c++ You will have to write a program but instead of having 1 objective you will write code snippets with informative COUTS and comments
in c++ You will have to write a program but instead of having 1 objective you will write code snippets with informative COUTS and comments as to what part of the code corresponds to which part of the assignment. This lab uses Mug you can get a copy of Mug.h and Mug.cpp here. https://drive.google.com/drive/folders/1Jr3QmSoZlOGCHdWwSGE91tisA1x8Rwax
Task 1: In code create and initialize an 2 ints, a double, a char, and a mug (in that order)
Task 2: In code Create 5 pointers to the 5 variables created in Task 1
Task 3: In code Print out the 5 memory locations of your variables. For the char* type you have to cast it (otherwise itll think its a C-stringmore on this later) For example if you have a char* k that holds the memory address of a char variable, you would cout it by saying static_cast
Task 4: In code Print out the size of each variable type: int, double, char, and mug, by using the sizeof(). For example, if I have an int x, I can print out sizeof(x) and it will give me the number of bytes in memory x takes up. THIS MIGHT BE DIFFERENT FROM COMPUTER TO COMPUTER.
Task 1a: In code Create an integer array of 5 elements and use a for loop to initialize these array elements to anything you want. Then cout the array (so if my array name is p, Ill cout<
Task 3: In In code use the sizeof function on the array to cout the size of the array
Task 1: In code create a for loop that prints out all the contents of an array without using []
Task 2: In code: create an array of 5 doubles and redo task 1 (i.e. double arrayD[5];).
Part 4 Pointing to the future: Wrapping up the pointers lab Task 1: In code create a pointer to a pointer (int **p that points to another integer pointer, int*q which points to some integer int x (so q holds xs memory location and **p holds qs memory location).
Task 3: In code: use p (and only p) to add one to xs value. hint: parenthesis are your friends. Extra credit 2a: In code Write some code to help you figure out the size of an int pointer and a double pointer.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started