1. #define LAT_CINCINNATI 38.898556 #define LONG_CINCINNATI -77.037852 These are
ID: 3592923 • Letter: 1
Question
1.
#define LAT_CINCINNATI 38.898556
#define LONG_CINCINNATI -77.037852
These are
a)variables of type double
b)variables of unknown type
c)enumeration double types
d)constants
2.
What statement is true about the following code:
char c;
cin >> c;
switch (c)
{
case 'a':
break;
case 'b':
break;
}
a)char cannot be used in a switch
b)a switch must have a default statement
c)this code shows a legal switch statement
d)'a' and 'b' should be "a" and "b"
3.
The following code will compile with no issues.
const string STARS = "*****";
main ()
{
STARS = "*******";
}
a)True
b)False
4.By convention, the names of constants should be in upper case letters.
a)True
b)False
5.
The approximate value of Lieb's square ice constant is 1.53960.
Show how to define this as a constant named LIEBS using a pre-processor directive:
Show show to define this as a constant named LIEBS using a const declaration:
Write just the statements needed to do this. Do not include an entire program.
6.Defining an enumeration type means that you are defining a new data type.
a)True
b)False
7.Show the code to define an enumeration type called Days, with possible values SUN, MON, TUE, WED, THU, FRI, SAT.
8.
You are writing a program for a veterinarians office, and have defined the following:
enum Animal { RODENT, CAT, DOG, HAMSTER };
Show the code to declare a variable named patient of type Animal and initialize it to an appropriate value.
9.
Given the definition of Animal in the previous question, the following code would be legal to declare a CAT.
Animal patient = 1;
a)true
b)false
10.
Given the definition of Animal in the previous question, the following code is legal.
if (patient == RODENT)
{
//do something rodenty
}
a)True
b)false
Explanation / Answer
As per Chegg guidelines Answering first 4 questions answer:
1.
#define LAT_CINCINNATI 38.898556
#define LONG_CINCINNATI -77.037852
These are
a)variables of type double
b)variables of unknown type
c)enumeration double types
d)constants
Answer Explanation:
The syntax for creating a constant using #define in the C language is:
#define CNAME value or expression
Correct Answers is d. constants
What statement is true about the following code:
char c;
cin >> c;
switch (c)
{
case 'a':
break;
case 'b':
break;
}
Answer Explanation:
A switch statement can have an optional default case, which must appear at the end of the switch.
Correct Answer is b. a switch must have a default statement
3.
The following code will compile with no issues.
const string STARS = "*****";
main ()
{
STARS = "*******";
}
Answer Explanation:
As per C language, there is no such string data type available. So it will not compile.
Correct Answer: False
4.By convention, the names of constants should be in upper case letters.
a)True
b)False
Correct Answer: True
As per naming convention constants should appear in upper case letters.
Thanks a lot. Please let me know if you have any doubt.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.