Write C++ code (perhaps around 20-30 lines of code) and make it compile and run showing how to use it. It can be a single code example, or multiple code examples to demonstrate the following. a. char b. short c. int d. sizeof e. typedef f. enum g. struct h. union i. pointer
Write C++ code (perhaps around 20-30 lines of code) and make it compile and run showing how to use it. It can be a single code example, or multiple code examples to demonstrate the following.
a. char
b. short
c. int
d. sizeof
e. typedef
f. enum
g. struct
h. union
i. pointer
![](/static/compass_v2/shared-icons/check-mark.png)
Algorithm:
1. Declare a char variable c and assign it a value of 'A'.
2. Declare a short variable s and assign it a value of 123.
3. Declare an int variable i and assign it a value of 123456.
4. Print the size of each of the above variables in bytes.
5. Define a new type myInt as an alias for int.
6. Declare an enum Color and assign it a value of RED.
7. Declare a struct Point with two int variables x and y, and assign them values of 1 and 2 respectively.
8. Declare a union Data with an int and float variable, and assign the int variable a value of 42.
9. Declare an int variable j and assign it a value of 10.
10. Declare a pointer to int and assign it the address of j.
11. Print the value pointed to by the pointer.
12. End.
Step by step
Solved in 4 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)