A SIMPLE CALCULATION WEEK 2 Flashcards

1
Q

Application programs receive input from the user, convert it using program variables and instructions, and display the output to the user.
Programs store input data in RAM, retrieve it, and convert it using the CPU’s ALU and FPA.
A program for calculating the area of a circle involves program variables and instructions for accepting user input, calculating the area, storing the result, and displaying it to the user.
Constant values in a program can be numbers, characters, or string literals, and are defined with a specific type.
Numeric constants can have a suffix and/or decimal point to indicate their type, and can also be defined in hexadecimal representation with a prefix of 0x.
The const keyword can be used to make a variable unmodifiable, such as when defining a constant like pi to 8 significant digits.

A

Introduction
Definition: Overview of program input, processing and output operations, and the role of program variables and instructions in directing these operations.

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

Definition: Application programs receive input from the user, convert that input into output and display the output to the user. The user enters the input through a keyboard or similar device and receives converted output through a monitor or similar device. Program instructions store the input data in RAM, retrieve that input data from RAM, convert it using the ALU and FPA in the CPU and store the result in RAM as illustrated in the figure below.

A

Term: Introduction

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

Definition: Constant values in a program can be numbers, characters, or string literals. Each constant is of a specific type. We define the type of a constant, like the type of a variable, when we declare the constant.

A

Term: Constant Values

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

Definition: Numeric constants are defined by specifying the type of a numeric constant by a suffix, if any, on the value itself and possibly a decimal point. To define a numeric constant in hexadecimal representation, we prefix the value with 0x.

A

Term: Numeric Constants

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

Definition: All character constants are of char type. The ways of defining a character constant include: the digit or letter enclosed in single quotes, the decimal value from the collating sequence, and the hexadecimal value from the collating sequence. The single-quotes form is the preferred form, since it is independent of the collating sequence of the execution environment.

A

Term: Character Constants

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

Definition: Character constants include special actions and symbols, which are defined by escape sequences. The backslash () before each symbol identifies the symbol as part of an escape sequence. Escape sequences are relatively independent of the execution environment but their decimal values vary with the collating sequence of the execution environment and should be avoided.

A

Term: Escape Sequences

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

Definition: A string literal is a sequence of characters enclosed within a pair of double quotes. For example, “This is C\n”. The \n character constant adds a new line to the end of the string.

A

Term: String Literals

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

Definition: The scanf(…) instruction accepts data from the user and stores that data in memory at the address of the specified program variable. The instruction takes the form: scanf(format, address); Format is a string literal that describes how to convert the text entered by the user into data stored in memory. Format contains the conversion specifier for translating the input characters.

A

Term: Simple Input

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

Definition: Conversion specifiers begin with a % symbol and identify the type of the destination variable. The most common specifiers include %d for integers, %f for floats, and %s for strings. A more complete table is listed in the chapter entitled Input and Output.

A

Term: Input Conversion Specifiers

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

Answer: Address contains the address of the destination variable. The prefix & is used to refer to the ‘address of’ a variable. The argument in the call to scanf() is the address of the variable, not the value of the variable. Missing & in the call to scanf() is a common mistake for beginners and can cause a run-time error.

A

Address

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

Answer: To store the area of a circle in memory involves four program instructions: defining a variable to hold the area, squaring the radius, multiplying the square by π, and assigning the result to the defined variable. The multiplication operation takes the form operand * operand. The assignment operation stores the value of an expression in the memory location of the destination variable. Assignment takes the form destination = expression

A

Flashcard: Computation

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

Answer: Character constants are of char type and can be defined using the digit or letter enclosed in single quotes, the decimal value from the collating sequence, or the hexadecimal value from the collating sequence. The single-quotes form is preferred since it is independent of the collating sequence of the execution environment. Escape sequences define special actions and symbols in character constants. The backslash () before each symbol identifies the symbol as part of an escape sequence. String literals are sequences of characters enclosed within a pair of double quotes.

A

Flashcard: Character Constants

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

Answer: The scanf() instruction accepts data from the user and stores it in memory at the address of the specified program variable. The instruction takes the form scanf(format, address), where format is a string literal that describes how to convert the text entered by the user into data stored in memory. Conversion specifiers in format begin with a % symbol and identify the type of the destination variable.

A

Flashcard: Simple Input

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

Answer: C supports several data types, including int for integers, float for floating-point numbers, double for double-precision floating-point numbers, char for characters, and void for no value. Arrays are collections of elements of the same data type. Pointers are variables that store the address of another variable. Structures are collections of variables of different data types. Unions are variables that can hold different data types at different times.

A

Flashcard: Data Types

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

What is Simple Output in C programming?

A

Simple Output is a way to report the value of a variable or expression to the user in C programming. The printf(…) instruction is used to perform this operation. The format and expression are arguments in our call to printf(). Format is a string literal describing how to convert data stored in memory into text readable by the user. It contains the conversion specifier, which begins with a % symbol and identifies the type of the source variable. Expression is a placeholder for the source variable. The printf() procedure copies the variable and converts it into the output text. The default number of decimal places displayed by %f and %lf is 6. To display two decimal places, we write %.2f or %.2lf.

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

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

A

expression

17
Q

is a string literal describing how to convert data stored in memory into text readable by the user. contains the conversion specifier and any characters to be output directly. The conversion specifier begins with a % symbol and identifies the type of the source variable. The most common specifiers are listed below.

A

format