From the course: C Essential Training

Solution: Make variables and constants - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

Solution: Make variables and constants

(upbeat music) - [Instructor] Here is how I wrote my solution. On line 5, I create integer variable a, and I immediately assign it the value 16. On line 6, I create the constant character b, which must be immediately assigned to a character. I chose Z for a constant. This is the only way to construct the assignment. You cannot have a statement later that modifies constant b. Build and run, and here's the results. In this variation, I assigned the value of 16 to variable a and its own statement at line 8. This solution is also acceptable, and I hope you devised something similar. Remember, constants are declared by using the const keyword as shown here at line 6, and they must be assigned a value immediately in the same statement.

Contents