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

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









