1/152
Looks like no tags are added yet.

Will this following code compile and run?
It will compile but not run as expected

Will the following compile and run?
Yes
Which symbol is used for comments in C?
/ / for single line and /* */ for multi line
What is the first part of the code that is usually in your C file?
#include <stdio.h>
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
What will the following code portion output?
int x = 5
printf(“%d", ++x);
6

Fill in the blank:
for (int i = 1; 1 < n; i+=3)
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;
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
What does the printf function do in C?
Prints text to the terminal
What is the purpose of the #include directive in C?
Copies the headers so we can call a built in function
In C, how are strings represented?
As an array of characters, terminated by a null character (\0)
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
What does the following for loop do?
for (int i = 0; i < 5; i += 2)
{
printf(“%d”, i);
}
Prints numbers 0, 2, 4
What is the scope of a variable declared inside a function?
It is local to that function and cannot be accessed outside it
What is te output of the snippet of code within a valid main algorithm?
float x = 5.7;
printf(“%d", (int)x);
5
What happens if you try to access an array element out of bounds?
It causes undefined behavior
What is the default value of an int variable in C?
Undefined
Which loop is guaranteed to run at least once in C?
Do-While loop
What is the correct way to declare a string in C?
char str[ ] = “Hello";
What is the hardware that's in a computer?
Keyboard, screen, mouse, solid-state disks, hard disks, memory, DVD drives and processing units.
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.
Gordon Moore
Co-founder of intel and the person who identified this trend in the 1960s
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
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.
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.
What is ALU?
Arithmetic and Logic Unit - This “manufactoring” section performs calculations and makes decisions. Part of CPU
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.
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
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.
What is a bit?
Short for “binary digit" -- a digit that can assume 0 or 1
Special symbols:
$ 2 % * ( ) - + ; , ? /
American Standard Code for Information Interchange
ASCII
Unicode characters:
COmposed of one, two, three, or four bytes (8, 16, 24, or 32 bits)
What is a field?
A group of characters or bytes that conveys meaning.
Consists of uppercase letters, lowercase letters, and decimal digits.
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.
What is a file?
Group of related records
Contains arbitrary data in arbitrary formats.
What is a database?
A collection of data organized for easy access and manipulation.
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.
Relational Database
Most popular model, in which data is stored in simple tables
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.
What are the three general types of languages?
Machine languages, assembly languages, and high-level languages.
What is a compiler?
Translator program that convert high-level language source code into machine language.
What is an interpreter?
Execute high-level language programs directly and avoifds compilation delays, but your code runs slower than compiled programs
What is C widely used for?
To develop systems that demand performance: operating systems, embedded systems, real-time systems, communications systems.
What is a function?
Pieces that a C program consists of.
You can program all the functions you need to form a C program.
What is software reuse?
Using existing functions, libraries, or code created by ohers instead of creating it by scratch.
What is char?
Character data type (a number that represents an alphanumeric character)
What is an int?
Integer data type
What is main?
An “integer” function, it runs and returns a whole number.
What is return 0?
Tells us that there is no errors in the program main
When should you define variables?
Before they are used.
What can an identifier consist of?
letters, digits, and underscores, but may not begin with a digit
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
What does “%” mean?
Remainder
What is a condition?
An expression that can be true or false
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
What does an oval represent in a flowchart?
A start or end point
What do the arrows represent in a flowchart?
A line is a connector that shows relationships between the representative shapes.
What does the paraellogram represent in a flowchart?
Input / Output
What does a rectangle mean in a fowchart?
A process
What does a diamond mean in a flowchart?
A decision
What does a loop do?
Executes statements while some loop-continuation condition remains true.
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.
What does counter < 5 mean?
The loop would execute only 4 times.
What is off-by-one error?
Common logic error
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*
When do infinite loops occur?
When the loop-continuation condition never becomes false.
What should you ensure in a while statement?
Ensure that you do not place a semicolon immediately after a while statement's header
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.
What should you ensure in a sentinel-controlled loop?
Ensure that the sentinel value is eventually input
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)
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)
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)
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)
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)
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)
What are floating-point literals?
Such values in the source code
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.
What is a while loop?
Tests its loop-continuation condition before executing the loop body.
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.
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
What does “&&” mean?
And
What does “||” mean?
Or
What does “!” mean?
Not
Defining functions:
The statements defining the function are written once and are hidden from other functions.
What does the function “sqrt" mean?
Calls function sqrt to calculate the square root and prints the result.
What does the function “cbrt" mean?
Cube root
What does the function “exp" mean?
Exponential function
What does the function “log" mean?
Natural logarithm
What is the function “main?"
A group of calls ro function that perform the bulk of the program's work.
What is the divide-and-conquer approach?
Makes program development more manageable
What is software reusability?
Building new programs by using existing functions.
What is abstraction?
With good naming and definition, you can create programs from standardized functions that accomplish specific tasks, rather than custom code.
What is decomposition?
To break such a function into smaller functions.
What happens if you forget a semicolon at the end of a function prototype?
It is a syntax error
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.
What does return-value-type mean?
Type of result returned to the caller
What does void mean?
Indicates that a function does not return a value
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