Engineering Computation and Analysis

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/152

encourage image

There's no tags or description

Looks like no tags are added yet.

153 Terms

1
New cards
<p>Will this following code compile and run?</p>

Will this following code compile and run?

It will compile but not run as expected

2
New cards
<p>Will the following compile and run?</p>

Will the following compile and run?

Yes

3
New cards

Which symbol is used for comments in C?

/ / for single line and /* */ for multi line

4
New cards

What is the first part of the code that is usually in your C file?

#include <stdio.h>

5
New cards

What does the return 0; statement indicate in the main() function of a C program?

Tell operating system whether or not there is an error in execution

6
New cards

What will the following code portion output?

int x = 5
printf(“%d", ++x);

6

7
New cards
<p>Fill in the blank:</p>

Fill in the blank:

for (int i = 1; 1 < n; i+=3)

8
New cards

If you are creating a variable for a whole number that represents a bowling score (0-300), what is the best presentation?

int Bowling_Scores;

9
New cards

What is the difference between == and = in C?

== is used to compare two values for equality, while = is used to assign a value to a variable

10
New cards

What does the printf function do in C?

Prints text to the terminal

11
New cards

What is the purpose of the #include directive in C?

Copies the headers so we can call a built in function

12
New cards

In C, how are strings represented?

As an array of characters, terminated by a null character (\0)

13
New cards

What is the output of the snippet of code within a valid Main?

int i;
for (i=0; i < 5; i++)
{
printf(“%d", i);
}

0 1 2 3 4

14
New cards

What does the following for loop do?

for (int i = 0; i < 5; i += 2)
{
printf(“%d”, i);
}

Prints numbers 0, 2, 4

15
New cards

What is the scope of a variable declared inside a function?

It is local to that function and cannot be accessed outside it

16
New cards

What is te output of the snippet of code within a valid main algorithm?

float x = 5.7;
printf(“%d", (int)x);

5

17
New cards

What happens if you try to access an array element out of bounds?

It causes undefined behavior

18
New cards

What is the default value of an int variable in C?

Undefined

19
New cards

Which loop is guaranteed to run at least once in C?

Do-While loop

20
New cards

What is the correct way to declare a string in C?

char str[ ] = “Hello";

21
New cards

What is the hardware that's in a computer?

Keyboard, screen, mouse, solid-state disks, hard disks, memory, DVD drives and processing units.

22
New cards

What is Moore's law?

The observaton that the number of transistors on a microchip doubles roughly every two years, while the cost of computers is halved.

23
New cards

Gordon Moore

Co-founder of intel and the person who identified this trend in the 1960s

24
New cards

What is input unit?

This “receiving” section obtains information (data and computer programs) from input devices and places it at the other units’ disposal for processing

25
New cards

What is output unti?

This “shipping" sections takes information the computer has processed and places it on various output devices to make it available outside the computer.

26
New cards

What is memory unit?

This rapid-access, relatively low-capacity “warehouse” section retains information entered through the input unit, making it immediately available for processing when needed.

Also retains processed information until it can be placed on output devices by the output unit.

27
New cards

What is ALU?

Arithmetic and Logic Unit - This “manufactoring” section performs calculations and makes decisions. Part of CPU

28
New cards

What is CPU?

Central Processing Unit - This “administrative” section coordinates and supervises the operation of the other sections. Examples: tells the input when to read information into the memory unit.

29
New cards

What is secondary storage unit?

This is the long-term, high-capacity “warehousing" section.

Examples: solid-state drives (SSDs), USB flash drives, hard drives and read/write Blu-ray drives

30
New cards

What is data hierarchy?

Data items processed by computers that become larger and more complex in structure as we progress from the simplest data items (bits) to richer ones, such as characters and fields.

31
New cards

What is a bit?

Short for “binary digit" -- a digit that can assume 0 or 1

32
New cards

Special symbols:

$ 2 % * ( ) - + ; , ? /

33
New cards

American Standard Code for Information Interchange

ASCII

34
New cards

Unicode characters:

COmposed of one, two, three, or four bytes (8, 16, 24, or 32 bits)

35
New cards

What is a field?

A group of characters or bytes that conveys meaning.

Consists of uppercase letters, lowercase letters, and decimal digits.

36
New cards

What is a record?

Group of related fields.

Employee record - employee identification number, name, address, hourly pay rate, year-to-date earnings, amount of taxes withheld.

37
New cards

What is a file?

Group of related records

Contains arbitrary data in arbitrary formats.

38
New cards

What is a database?

A collection of data organized for easy access and manipulation.

39
New cards

What is a table?

Includes records and data

Table of students might include: first name, last name, major, year, student ID number and grade-point average.

The data for each student is a record, and the individual pieces of information in each record are the fields.

40
New cards

Relational Database

Most popular model, in which data is stored in simple tables

41
New cards

What is data mining?

The process of searching through extensive collections of data, often big data, to find insights that can be valuable to individuals and organizations.

42
New cards

What are the three general types of languages?

Machine languages, assembly languages, and high-level languages.

43
New cards

What is a compiler?

Translator program that convert high-level language source code into machine language.

44
New cards

What is an interpreter?

Execute high-level language programs directly and avoifds compilation delays, but your code runs slower than compiled programs

45
New cards

What is C widely used for?

To develop systems that demand performance: operating systems, embedded systems, real-time systems, communications systems.

46
New cards

What is a function?

Pieces that a C program consists of.

You can program all the functions you need to form a C program.

47
New cards

What is software reuse?

Using existing functions, libraries, or code created by ohers instead of creating it by scratch.

48
New cards

What is char?

Character data type (a number that represents an alphanumeric character)

49
New cards

What is an int?

Integer data type

50
New cards

What is main?

An “integer” function, it runs and returns a whole number.

51
New cards

What is return 0?

Tells us that there is no errors in the program main

52
New cards

When should you define variables?

Before they are used.

53
New cards

What can an identifier consist of?

letters, digits, and underscores, but may not begin with a digit

54
New cards

How should variable names be written?

Start with a lowercase letter


Multiple-word variables:
Separate words with underscores: total_commissions
Run words together and begin each subsequent word with a capital letter: totalCommissions

55
New cards

What does “%” mean?

Remainder

56
New cards

What is a condition?

An expression that can be true or false

57
New cards

If statement:

Makes a decision based on a condition's value
if true, the statemnent in the if statement's body executes,
otherwise, it does not

58
New cards

What does an oval represent in a flowchart?

A start or end point

59
New cards

What do the arrows represent in a flowchart?

A line is a connector that shows relationships between the representative shapes.

60
New cards

What does the paraellogram represent in a flowchart?

Input / Output

61
New cards

What does a rectangle mean in a fowchart?

A process

62
New cards

What does a diamond mean in a flowchart?

A decision

63
New cards

What does a loop do?

Executes statements while some loop-continuation condition remains true.

64
New cards

What does Counter-Controlled Iteration require?

The name of a control variable, the initial value of the control variable, the increment (or decrement) by which the control variable is modified in each iteration, and, the loop-continuation condition that tests for the final value of the control variable to determine whether looping should continue.

65
New cards

What does counter < 5 mean?

The loop would execute only 4 times.

66
New cards

What is off-by-one error?

Common logic error

67
New cards

What is the general format of a for statement?

for (initialization; loopContinuationCondition; increment) {
statement
}

Initiaization - names the control variable and provides its initial value
loopContinuationCondition - determines whether the loop should continue executing
increment - modifies the control variables value after executing the statement so the loop-continuation condition eventually becomes false.
The two semicolons are required*

68
New cards

When do infinite loops occur?

When the loop-continuation condition never becomes false.

69
New cards

What should you ensure in a while statement?

Ensure that you do not place a semicolon immediately after a while statement's header

70
New cards

What should you ensure in a counter-controlled loop?

Ensure that you increment or decrement the control variable so the loop-continuation condition eventually becomes false.

71
New cards

What should you ensure in a sentinel-controlled loop?

Ensure that the sentinel value is eventually input

72
New cards

How would you write a for statement for “Vary the control variable from 1 to 100 in increments of 1?”

for (int i = 1; i <= 100; ++i)

73
New cards

How would you write a for statement for “Vary the control variable from 100 to 1 in increments of -1?”

for (int i = 100; i >= 1; --i)

74
New cards

How would you write a for loop statement for “Vary the control variable from 7 to 77 in increments of 7?”

for (int i = 7; i <= 77; i += 7)

75
New cards

How would you write a for loop statement for “Vary the control variable from 20 to 2 in increments of -2?”

for (int i = 20; i >= 2; i -= -2)

76
New cards

How would you write a for loop statement for “Vary the control variable over the valus 2, 5, 8, 11, 14, and 17?”

for (int j = 2; j <= 17; j += 3)

77
New cards

How would you write a for loop statement for “Vary the control variable over 44, 33, 22, 11, 0?”

for (int j = 44; j >= 0; j -= 11)

78
New cards

What are floating-point literals?

Such values in the source code

79
New cards

What is multiple selection?

An algorithm will contain a series of decisions that test a variable or expression separately for each of the integer valus it may assume, then perform different actions.


Consists of a series of case labels, an optional default case and statements to execute for each case.

80
New cards

What is a while loop?

Tests its loop-continuation condition before executing the loop body.

81
New cards

What is a do-while loop statement?

Tests its lop-continuation condition after executing the loop body, so the loop body always executes at least once.

82
New cards

What is a break?

A break executed in a loop or switch statement, immediately exits from that statement. Common uses of a break are to escape early from a loop or skip the remainder of a switch

83
New cards

What does “&&” mean?

And

84
New cards

What does “||” mean?

Or

85
New cards

What does “!” mean?

Not

86
New cards

Defining functions:

The statements defining the function are written once and are hidden from other functions.

87
New cards

What does the function “sqrt" mean?

Calls function sqrt to calculate the square root and prints the result.

88
New cards

What does the function “cbrt" mean?

Cube root

89
New cards

What does the function “exp" mean?

Exponential function

90
New cards

What does the function “log" mean?

Natural logarithm

91
New cards

What is the function “main?"

A group of calls ro function that perform the bulk of the program's work.

92
New cards

What is the divide-and-conquer approach?

Makes program development more manageable

93
New cards

What is software reusability?

Building new programs by using existing functions.

94
New cards

What is abstraction?

With good naming and definition, you can create programs from standardized functions that accomplish specific tasks, rather than custom code.

95
New cards

What is decomposition?

To break such a function into smaller functions.

96
New cards

What happens if you forget a semicolon at the end of a function prototype?

It is a syntax error

97
New cards

What is going on in this?
int square (int number); // function prototype

Int in parenthesis informs the compiler that square expects to receive an integer value from the caller.
Int to the left of the function name informs the compiler that square returns an integer result to the caller.

98
New cards

What does return-value-type mean?

Type of result returned to the caller

99
New cards

What does void mean?

Indicates that a function does not return a value

100
New cards

What is a parameter-list?

A comma-separated list of parameters required to call the function when it's called:
void for no parameters
Each parameter must include its type