Simple Calculation Flashcards

1
Q

Question: What is the role of application programs in the input-output process of a computer?

A

Answer: Application programs receive input from the user, convert it into output, and display the output to the user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Question: What are the devices used by the user to input and receive output data?

A

Answer: The user inputs data through a keyboard or similar device and receives converted output through a monitor or similar device.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Question: How does a program operate on data stored in program variables?

A

Answer: A program operates on data stored in program variables using program instructions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Question: What is the purpose of the chapter that describes how to write an interactive program for calculating the area of a circle?

A

Answer: The chapter describes how to write an interactive program for calculating the area of a circle.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Question: What are constant values in a program, and what types can they be?

A

Answer: Constant values in a program can be numbers, characters, or string literals, and each constant is of a specific type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Question: How do we define the type of a constant in a program, and what are numeric constants?

A

Answer: We define the type of a constant in a program, like the type of a variable, when we declare the constant. Numeric constants are constants that are numeric values, which we can specify by a suffix, if any, on the value itself and possibly a decimal point.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Question: How do we define a numeric constant in hexadecimal representation?

A

Answer: To define a numeric constant in hexadecimal representation, we prefix the value with 0x.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Question: How do we define the constant pi to 8 significant digits, and what is the purpose of the const keyword in this context?

A

Answer: We select the float type and write const float pi = 3.14159f to define the constant pi to 8 significant digits. The const keyword qualifies the value stored in the ‘variable’ pi as unmodifiable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Question: What are the three ways to define a character constant, and what type are all character constants?

A

Answer: The three ways to define a character constant are the digit or letter enclosed in single quotes, the decimal value from the collating sequence, and the hexadecimal value from the collating sequence. All character constants are of char type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Question: What is the preferred form for defining a character constant, and why?

A

Answer: The preferred form for defining a character constant is the single-quotes form because it is independent of the collating sequence of the execution environment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Question: What are escape sequences, and how are they identified in character constants?

A

Answer: Escape sequences are special actions and symbols in character constants, and they are identified by the backslash () before each symbol.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Question: How do escape sequences vary with the collating sequence of the execution environment, and what caution should be taken?
.

A

Answer: Escape sequences are relatively independent of the execution environment, but their decimal values vary with the collating sequence of the execution environment. Therefore, they should be avoided

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Question: What is a string literal, and how is it defined?

A

Answer: A string literal is a sequence of characters enclosed within a pair of double quotes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Question: What does the \n character constant do in a string literal?

A

Answer: The \n character constant adds a new line to the end of the string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Question: What is the prefix used to refer to the address of a variable and why is it important to use it in the argument of the scanf() function?

A

Answer: The prefix & is used to refer to the address of a variable. It is important to use the & in the argument of the scanf() function because the argument should be the address of the variable being scanned, not the value of the variable itself. If the value of the variable is used instead of its address, it can lead to a run-time error or segmentation fault.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the form of the multiplication operation in C?

A

The multiplication operation in C takes the form: operand * operand, where operand is a placeholder for the variable or constant being multiplied, and * denotes the ‘multiply by’ operation.

17
Q

What is the form of the assignment operation in C?

A

The assignment operation in C takes the form: destination = expression, where destination is a placeholder for the destination variable, and expression refers to the value to be assigned to the destination variable. = denotes the ‘is assigned from’ operation.

18
Q

Why must the destination in an assignment operation be a variable in C?

A

The destination in an assignment operation must be a variable in C because assignment is a unidirectional operation, meaning that the value of an expression can only be stored in the memory location of a variable, which must have a location in memory.

19
Q

What is the explicit way to calculate the square of a number in C?

A

The explicit way to calculate the square of a number in C is by multiplying the number by itself. For example, to calculate the square of the radius in the context of the area of a circle formula, we use the expression radius * radius.

20
Q

Question: What is the printf() instruction used for and what is its syntax?

A

Answer: The printf() instruction is used to report the value of a variable or expression to the user. Its syntax is printf(format, expression).

21
Q

Question: What are the arguments in the call to printf()?

A

Answer: The arguments in the call to printf() are format and expression.

22
Q

Question: What is format in printf() and what does it contain?

A

Answer: format is a string literal that describes how to convert data stored in memory into text readable by the user. It contains the conversion specifier and any characters to be output directly.

23
Q

Question: What is the conversion specifier and how is it identified?

A

Answer: The conversion specifier is the part of format that identifies the type of the source variable. It begins with a % symbol.

24
Q

Question: What are the most common specifiers used in printf()?

A

Answer: The most common specifiers used in printf() are %d, %f, %c, and %s.

25
Q

Question: How do you display two decimal places using printf()?

A

Answer: To display two decimal places, we write %.2f or %.2lf.

26
Q

Question: What is expression in printf() and what does it do?

A

Answer: expression is a placeholder for the source variable. The printf() procedure copies the variable and converts it into the output text.

27
Q

Question: What is the default number of decimal places displayed by %f and %lf?

A

Answer: The default number of decimal places displayed by %f and %lf is 6.

28
Q

Question: What is the program in the example used for and what is its output?

A

Answer: The program in the example is used to calculate the area of a circle. Its output is “Area = 3.141593” when the radius is entered as 1.

29
Q

Question: How many decimal places does C round floating-point output to by default?

A

Answer: C rounds floating-point output to 6 decimal places by default.