Code 2.2 is for a program that demonstrates variable declarations and the use of literal and symbolic constants. The program prompts the user to input his/her weight (in grams) and year of birth. The program then calculates and displays the user’s weight (in pounds) and his/her age during the RIO Olympics year (2016). Type the code, compile (F9), and run (F10) Code 2.2. Save it as varsandconts.c. Answer the following: 1. What are the two symbolic constants used?  2. Show two methods of defining a symbolic constant named MAXIMUM that has a  value of 100. Provide the correct syntax. 3. Give an advantage of using a symbolic constant over a literal constant.   Code 2.2. A program that demonstrates the use of variables and constants. 1 /* Demonstrates variables and constants */ 2 #include 3 4 #define GRAMS_PER_POUND 454

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Code 2.2 is for a program that demonstrates variable declarations and the use of literal and symbolic constants. The program prompts the user to input his/her weight (in grams) and year of birth. The program then calculates and displays the user’s weight (in pounds) and his/her age during the RIO Olympics year (2016). Type the code, compile (F9), and run (F10) Code 2.2. Save it as varsandconts.c. Answer the following:
1. What are the two symbolic constants used? 
2. Show two methods of defining a symbolic constant named MAXIMUM that has a 
value of 100. Provide the correct syntax.
3. Give an advantage of using a symbolic constant over a literal constant.

 

Code 2.2. A program that demonstrates the use of variables and constants.
1 /* Demonstrates variables and constants */
2 #include <stdio.h>
3
4 #define GRAMS_PER_POUND 454
5
6 const int RIO_YEAR = 2016;
7
8 long weight_in_grams, weight_in_pounds;
9 int year_of_birth, age;
10
11 int main()
12 {
13
14 printf(“Enter weight (in grams): ”);
15 scanf(“%ld”, &weight_in_grams);
16
17 printf(“Enter your year of birth: ”);
18 scanf(“%d”, &year_of_birth);
19
20 weight_in_pounds = weight_in_grams / GRAMS_PER_POUND;
21 age = RIO_YEAR – year_of_birth;
22
23 printf(“\n\nYour weight in pounds is %d”, weight_in_pounds);
24 printf(“\nAge during the RIO Olympics year: %d.”, age);
25
26 return 0;
27 }

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education