Chapter 2 COSC-1436 (100% Verified)
Declare an int constant , MonthsInYear, whose value is 12. correct answers const int MonthsInYear=12; Declare an int constant MonthsInDecade whose value is the value of the constant MonthsInYear (already declared ) multiplied by 10. correct answers const int MonthsInDecade=MonthsInYear*10; Define a macro MAX_STUDENTS to be the value 100. correct answers #define MAX_STUDENTS 100 Define a macro WRONG to represent the false value . correct answers #define WRONG-false; Define a macro RIGHT to represent the true value . correct answers #define RIGHT-true; Write a declaration for two variables , price and cost, that can hold numbers with decimal places. correct answers float price; float cost; Write a declaration for variables length, width, and area that can hold values like 13.5 and 14.6. correct answers double length; double width; double area; Write a declaration for a variable channel that can hold TV channel numbers (1 to 900) and a variable hours_recorded that can hold the number of hours of TV recorded (numbers like 1.0 or 3.5). correct answers int channel; float hours_recorded; Write a statement that declares an int variable age and initializes it to 15. correct answers int age=15; Write a statement that declares two int variables , named num and val and initializes each to 5. correct answers int num=5; int val=5; Write statements to declare and initialize two variables : one, named element _number can hold any of the integer values 1 through 118; the other, named atomic_weight can hold the atomic weight of the given element ; atomic weights are values like 3.76. In the declaration , initialize the variables to the values for oxygen, which is element number 8 and has an atomic weight of 15.9994. correct answers double oxygen = 8; int element_number = oxygen; oxygen = 15.9994; double atomic_weight = oxygen;
Written for
- Institution
- Chapter 2 COSC-1436
- Course
- Chapter 2 COSC-1436
Document information
- Uploaded on
- September 6, 2023
- Number of pages
- 13
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
declare an int constant monthsinyear whose valu
Also available in package deal