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 avalue 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 34 #define GRAMS_PER_POUND 45456 const int RIO_YEAR = 2016;78 long weight_in_grams, weight_in_pounds;9 int year_of_birth, age;1011 int main()12 {1314 printf(“Enter weight (in grams): ”);15 scanf(“%ld”, &weight_in_grams);1617 printf(“Enter your year of birth: ”);18 scanf(“%d”, &year_of_birth);1920 weight_in_pounds = weight_in_grams / GRAMS_PER_POUND;21 age = RIO_YEAR – year_of_birth;2223 printf(“\n\nYour weight in pounds is %d”, weight_in_pounds);24 printf(“\nAge during the RIO Olympics year: %d.”, age);2526 return 0;27 }
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here