Declare an int constant , MonthsInYear, whose value is 12.
answer
const int MonthsInYear=12;
question
Declare an int constant MonthsInDecade whose value is the value of the constant MonthsInYear (already declared ) multiplied by 10.
answer
const int MonthsInDecade=MonthsInYear*10;
question
Define a macro MAX_STUDENTS to be the value 100.
answer
#define MAX_STUDENTS 100
question
Define a macro WRONG to represent the false value .
answer
#define WRONG-false;
question
Define a macro RIGHT to represent the true value .
answer
#define RIGHT-true;
question
Write a declaration for two variables , price and cost, that can hold numbers with decimal places.
answer
float price;
float cost;
question
Write a declaration for variables length, width, and area that can hold values like 13.5 and 14.6.
answer
double length;
double width;
double area;
question
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).
answer
int channel;
float hours_recorded;
question
Write a statement that declares an int variable age and initializes it to 15.
answer
int age=15;
question
Write a statement that declares two int variables , named num and val and initializes each to 5.
answer
int num=5;
int val=5;
question
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.