Simple Calculation Flashcards
Question: What is the role of application programs in the input-output process of a computer?
Answer: Application programs receive input from the user, convert it into output, and display the output to the user.
Question: What are the devices used by the user to input and receive output data?
Answer: The user inputs data through a keyboard or similar device and receives converted output through a monitor or similar device.
Question: How does a program operate on data stored in program variables?
Answer: A program operates on data stored in program variables using program instructions.
Question: What is the purpose of the chapter that describes how to write an interactive program for calculating the area of a circle?
Answer: The chapter describes how to write an interactive program for calculating the area of a circle.
Question: What are constant values in a program, and what types can they be?
Answer: Constant values in a program can be numbers, characters, or string literals, and each constant is of a specific type.
Question: How do we define the type of a constant in a program, and what are numeric constants?
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.
Question: How do we define a numeric constant in hexadecimal representation?
Answer: To define a numeric constant in hexadecimal representation, we prefix the value with 0x.
Question: How do we define the constant pi to 8 significant digits, and what is the purpose of the const keyword in this context?
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.
Question: What are the three ways to define a character constant, and what type are all character constants?
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.
Question: What is the preferred form for defining a character constant, and why?
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.
Question: What are escape sequences, and how are they identified in character constants?
Answer: Escape sequences are special actions and symbols in character constants, and they are identified by the backslash () before each symbol.
Question: How do escape sequences vary with the collating sequence of the execution environment, and what caution should be taken?
.
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
Question: What is a string literal, and how is it defined?
Answer: A string literal is a sequence of characters enclosed within a pair of double quotes.
Question: What does the \n character constant do in a string literal?
Answer: The \n character constant adds a new line to the end of the string.
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?
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.