final Flashcards

General Knowledge

1
Q

sudo

A

execute command as root or superuser, also change into another user besides root with permission

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

cal

A

displays calendar in the terminal

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

cd

A

change to specific directory

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

date

A

display or set date and time

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

diff

A

compares files line by line, prints lines that are different

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

find

A

allows you to find files that exist in a directory that matches some pattern

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

grep

A

searches input files and looks for lines that match one or more patterns

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

gzip

A

compress or expand a list of files

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

less

A

view a file one page at a time, backwards or forwards.

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

ls

A

lists files in the current working directory

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

man

A

displays user manual for other commands

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

more

A

view a file one page at a time

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

pwd

A

the present working directory

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

scp

A

copy files securely between computers over network

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

sort

A

sort file, arranges records in particular order, can sort file alphabetically

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

ssh

A

secure way to access computer over an unsecured network by remote machine, transferring files between two machines, and for executing commands on the remote machine

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

tar

A

access collection of files and place them into a highly compressed archive file

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

wc

A

count number of lines, words and characters in a file by ls -1

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

wget

A

download files from the web

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

what is an operating system?

A

programs that manages computer’s hardware, provides base for application of programs and acts as an intermediary between user and hardware

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

SLOC

A

source lines of code

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

what is a kernel?

A

program that has complete control over everything that occurs in the system

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

what is a shell?

A

program that is spawned by the kernel and interacts with the user, providing an interface between the OS and the user

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

what is a process?

A

executing/running instance of a program

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

what is a program?

A

executable file that is held in storage

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

what is a virtual machine?

A

Emulator of a computer system. Provides an interface identical to the underlying bare hardware. Creates illusion of multiple processes, each executing on its own processor with its own virtual memory.

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

what is the preprocessor directive #include?

A

tells preprocessor to get a particular header file and add it to the code before compilation, add information about standard library routines

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

STDIN

A

standard in, input stream

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

STDOUT

A

standard out, output stream

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

STDERR

A

standard error, output stream for error messages

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

what is the preprocessor directive #define?

A

allows the definition of macros that are constants that are used throughout the code eg. #define SECONDS 60

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

ls -l

A

long listing format in current directory

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

ls -tl

A

long listing format ordered by time/date

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

ls -al

A

long listing format showing files starting with ‘.’

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

The UNIX Philosophy is according to?

A

Brian Kernighan

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

difference between #inlcude and #include “filename”

A

first: file is in systems directory
second: file is in your directory

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

what does that standard library for the C programming language (libc) provide?

A

macros, type definitions, functions

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

Basics of UNIX Philosophy?

A

write programs that do one thing well, write programs to work together, write programs to handle text stream, everything is a file, write small single programs (modularity), ability to chain programs to peform complex tasks

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

UNIX Pipes

A

redirects output from one program into the input of another program, direct connection allows for simultaneous operations, data is transferred continuously

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

what does char *argv[ ] do?

A

stores an array of character strings

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

what is an array?

A

stores an ordered collection of things, where the order can be referenced by an index

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

what is the most basic program control structure?

A

if…else if…else

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

what does atoi( ) do?

A

ascii to integer, string to integer

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

what is a loop?

A

repetition of an action

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

what is a while loop?

A

executes while a condition is true

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

what is a for loop?

A

allows to specify 3 important aspects of looping in one place - start condition, end condition, and the change while looping

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

what are the 4 steps of problem solving?

A

understand, identify, develop plan, execute plan analyze and modify the problem

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

what are the four basic variable types?

A

int, char, float, double

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

what is a byte?

A

memory represented by bits; 1 or 0. Bits are grouped into bytes. Bytes are 8 bits long

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

what does the size of variable determine?

A

determines the range of numbers

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

two types of integers

A

signed or unsigned

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

signed integer

A

numbers can be positive, negative or zero

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

unsigned integer

A

numbers can be positive or zero

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

what is the range of integers?

A

4 bytes

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

how are negative signed ints represented?

A

in 2’s complement format, changing the 0’s to 1’s and 1’s to 0’s, then adding 1

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

why use 2’s complement?

A

fundamental arithmetic operations are identical to those on unsigned binary numbers, does not generate negative zero like other schemes

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

how many decimal digits of precision does a float have?

A

6 decimals

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

what is the range of floats?

A

4 bytes

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

how many decimal digits of precision does a double have?

A

15 decimals

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

what is the range of doubles?

A

8 bytes

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

what is the range of chars?

A

1 byte

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

why is a char a type of integer?

A

because C represents characters as integer numbers

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

int numbers are mapped to a character using?

A

ASCII, limited to 255 mappings or Unicode

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

arithmetic operators

A

addition, subtraction, multiplication, division, remainder

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

increment and decrement operators

A

change value by one, (++) or (–)

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

unary operators

A

operate on a single operand

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

prefix

A

perform action before any other action is taken

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

postfix

A

perform action after any other action is taken

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

what impacts result of a division operation?

A

based on the types of operands, if both are ints, result is an int. If one operand is floating, result can be float

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

what is modulo division and what is its restriction?

A

computes the remainder, and can only be used on integers

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

assignment operators

A

assigns value to integer, can also perform another operation ( += )

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

relational operators

A

used to form boolean expressions and decision making ( == ), ( != )

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

logical operators

A

used in boolean expressions, form basis of decision making ( && ), ( || ), ( ! )

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

sizeof operator

A

sizeof( ) returns the size of data as an unsigned long int

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

what is type casting?

A

the process of converting one type of data to another type FORMAT - fnum = (float) num

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

rules of thumb for comments

A

keep them brief, keep them to the point, three bears rule

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

different types of notations

A

Camel Case, Pascal Case, Hungarian, Snake Case, Kebab Case

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

Camel Case

A

first word is not capitalized - camelCase

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

Pascal Case

A

capitalize all words - PascalCase

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

what are the two types of Hungarian Notation?

A

systems hungarian, apps hungarian

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

Hungarian Notation

A

name starts with a lowercase prefix and indicates intention

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

Systems Hungarian

A

prefix indicates data types - intNumWidgets

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

Apps Hungarian

A

prefix indicates logical type - rowPosition and gives hint to the variable’s purpose

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

Snake Case

A

words within phrases are separated with an underscore - first_name

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

Kebab Case

A

word within phrases are separated with a hyphen - first-name

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

Conventions of Identifiers representing macros (#define)

A

written in uppercase with underscores separating words in a phrase

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

Conventions for system functions

A

names contain double underscores or begin with an underscore and a capital letter

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

naming rule for arrays

A

give them names that are plural

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

naming rule for booleans

A

prefixes such as is, has, can

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

naming rule for numbers

A

use meaningful descriptive prefixes, such as max, min, total

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

what are curly braces used for?

A

surround blocks of code

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

what are the two styles of using curly braces

A

new line, end line

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

New Line Curly Braces

A

each curly brace is on its own line

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

End Line Curly Braces

A

first curly brace is on the same line as statement, end brace aligned with statement

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

what does ASCII stand for?

A

american standard code for information interchange

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

history

A

gives history of all commands used in the terminal

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

mkdir

A

make a new directory or sub directory

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

who was the inventor and co inventor of the UNIX pipes?

A

Doug McIlroy (inventor), Ken Thompson (co-developer)

99
Q

advantages of VM

A

provides complete protection of system resources

100
Q

disadvantages of VM

A

VM concept is difficult to implement, difficult to duplicate underlying machine

101
Q

what are the four main components of a program structure?

A

preprocessor directives, main function, variables and statements, return function

102
Q

what are the three file streams?

A

STDIN, STDOUT, STDERR

103
Q

how to unzip gzip

A

gunzip “filename”.tar.gz

104
Q

how to unzip tar

A

tar -xvf “filename”.tar

105
Q

how to zip gzip

A

gzip “filename”.tar

106
Q

how to zip tar

A

tar cvf “filename”.tar *.c

107
Q

grep -i

A

not case restricted

108
Q

date -f

A

command uses a format string to parse the date rather than using the default

109
Q

Who developed the C language?

A

Brian Kernighan, Dennis Ritchie

110
Q

include

A

paste code of given file into the current file

111
Q

define

A

defines a macro which is a segment of code which is replaced by the value of the macro

112
Q

undef

A

cancels the definition of a macro

113
Q

ifdef

A

checks if a macro is defined by #define, if yes, execute the code

114
Q

ifndef

A

checks if a macro is not defined by #define, if yes, execute the code

115
Q

if

A

evaluates an expression or condition, it is it true, execute the code

116
Q

else

A

if condition is false, the #else code is executed

117
Q

elif

A

else if construct

118
Q

endif

A

ends an if-else set of statements

119
Q

error

A

causes preprocessor to report a fatal error. the rest of the line following #error are used as the error message

120
Q

warning

A

causes the preprocessor to report a warning

121
Q

pragma

A

used to provide additional information to the compiler.

122
Q

chgrp

A

change the group of ownership of a file or directory

123
Q

chmod

A

changes access mode of a file

124
Q

chown

A

change owner and group files, directories and links

125
Q

cp

A

copy files + directories

126
Q

mkdir

A

create directory

127
Q

more

A

allows you to view a file one page at a time

128
Q

mv

A

move files or drectories

129
Q

rm

A

remove files or directories

130
Q

history

A

shows all the last commands that have been recently used

131
Q

clear

A

used to bring the command line on top of the computer terminal

132
Q

echo

A

command in bash and C shells that writes arguments to standard output

133
Q

bg

A

job control command, resumes suspended jobs in the background

134
Q

all preprocessor directives

A

include, #define, #pragma, #if, #else, #undef, #ifdef, #ifndef, #endif, #warning, #error

135
Q

what does $ls -l | wc do?

A

lists files in current directory using long format, then prints out the number of lines, words, and characters generated by ls -l

136
Q

how to read in characters?

A

fgets( variable, size, stdin );
chop( variable );
fflush( stdin );

137
Q

how are ASCII characters stored?

A

in 8 bits – 2^7, 2^6, …, 2^0

138
Q

examples of string operations

A

strcat, strcmp, strcpy, strlen

139
Q

strcat

A

adds a string to the end of another string – (char *dest, char *source );

140
Q

strcmp

A

compares two strings, if the value is less than 0; s1 is less than s2, if the value is greater than 0; s2 is less than s1, if value is zero; the two strings are equal
( char *s1, char *s2 );

141
Q

strcpy

A

copies one string to another string;

( char *dest, char *source );

142
Q

strlen

A

returns with the length of characters in a string;
ex. char string[50];
int length;
length = strlen( string );

143
Q

arithmetic operators

A

+, -, *, /, %

144
Q

relational operators

A

==, !=, >, =

145
Q

logical operators

A

&&, ||, !

146
Q

assignment operators

A

a+=b, a-=b, a%=b, a*=b, a/=b

147
Q

sizeof( )

A

returns sizeof data ( data types, variables, …) as an unsigned long int

148
Q

casting

A

format: (type) expression
ex. int num = 12; float fnum = 2.3;
fnum = (float) num;

149
Q

why to use indentation?

A

to show which statements are grouped together, used heavily in nested loops

150
Q

why and when to use comments?

A

comment to help code reader, comment statements that are particularly confusing, comment blocks of code’s function

151
Q

function definition

A

group of statements that together perform a task

152
Q

function declaration

A

declare before the main( ) function, in source file containing the mainline

153
Q

function return

A

if function returns a value, data type must be defined in the function declaration

154
Q

passing parameters by value

A

value of parameter in calling routine is copied into the value of the parameter in the function.
changes made to parameter in function have no effect of the value of variable in the function.

155
Q

passing parameters by reference

A

method tells the function where the actual parameters are in memory.
variables in function are actual variables in the calling routine.
AKA : passes by means of pointers

156
Q

arrays and pointers

A

closely related, both contain address of a variable

ex. point = &array[0] OR pointer = array

157
Q

pointer declarations

A

every pointer to a specific data type, if *iPointer points to int x, *iPointer can be used anywhere x could be used

158
Q

pointer referencing

A

reference only has a variable that it is referencing.

datatype &referenceName = variable;

159
Q

pointer dereferencing

A

access and manipulation of data.
x = 5; int *p = &x;
*p = 2 : makes *p usable in the same cases as x

160
Q

preprocessor compilation

A

a separate program (cpp), invoked automatically by compiler before compilation

161
Q

compiler

A

converts all the C source code into object code and puts it into a file ending in “.o”, not directly executable unless you add code for all the library functions used by the function

162
Q

linker

A

links together object files into binary executable- includes: .o files from source file, pre-compiled object files called into library files (.a or .sh)

163
Q

.c files

A

source code files

164
Q

.h files

A

header files

165
Q

.o files

A

object files

166
Q

compiler option : -o

A

specify all output executable name(s)

167
Q

compiler option : -Wall

A

enables all warnings

168
Q

compiler option : -c

A

produces only compiled code

169
Q

compiler option : -lm

A

links with shared libraries

170
Q

compiler option : -ansi

A

enables support of ISO c89 style

171
Q

make

A

tool to simplify building program executables from many modules

172
Q

static library

A

the result of the linker making copies of all called library functions to the executable.
.a files are static libraries, created with the ar command

173
Q

archives (ar)

A

program that creates a static library and can
[c flag] - create static libraries
[r flag] - add object files in static library
[t flag] - list the name of .o files in the library
ex. ar rc libutil.a chop.o trim.o reduceSpace.o

174
Q

scanf( )

A

reads user input

ex. scanf( “%d”, &num );

175
Q

fscanf( )

A

stream pointer to a file stream

ex. int fscanf( FILE *stream, const char *format, …, );

176
Q

fgets( )

A

adjusts to read from any type of file, can specify buffer length to counter buffer overflow
ex. char *fgets( char *str, int n, FILE *p );

177
Q

fputs( )

A

writes string strPtr to file fp without the terminating byte ‘/0’, returns non-negative on success or EOF on error

178
Q

fprintf( )

A

similar to printf, but writes to a file instead of the screen, returns number of characters printed, excluding ‘/0’

179
Q

text files

A

sequence of ASCII characters stored on a disk, each character stored as one byte equivalent to C strings

180
Q

opening file

A

opened for reading/ writing, filename associated with file pointer, pointer points to structure with file info FILE *fp
ex. fp = fopen( “filename”, r );

181
Q

closing file

A

fclose( fp );

182
Q

reading file

A

done with the same commands to read from keyboard ( stdin stream )

183
Q

writing file

A

fprintf, fputs

184
Q

file pointer

A

FILE *fp

fp = fopen(“filename”, r);

185
Q

file modes : r

A

open an existing file from reading; start at the beginning

186
Q

file modes : w

A

create a new file for writing

187
Q

file modes : a

A

append - open an existing file; write at the end of the file

188
Q

file permission : chmod

A

octal mode : format ooo file
ex. $chmod 744 file;
symbolic mod:
ex. $chmod u+rwx, g+rw, o+r file;

189
Q

file permission : chown

A

change ownership of file, must have permission

ex. $chown owner filename;

190
Q

file permission : chgrp

A

change group of the file, must have permission

ex. $chgrp group filename

191
Q

file permission : file

A

determines file type

ex. $file testChop.c

192
Q

file permission : touch

A

changing a file’s modification date, can also create a blank file
ex. $touch chop.c

193
Q

struct definition

A

user-defined structure in C allows combination of different data types

194
Q

struct declaration

A
struct name strName;
struct name {
      member variable
      member variable
}
195
Q

passing structs to functions

A

three ways to pass structures:

  • pass individual members variables of struct by value to the function
  • pass individual members variables by pointer to func
  • pass entire structure by reference / pointer
196
Q

testing strategies

A
  • test systematically
  • test as you write
  • test boundary conditions
  • test pre- and post- conditions
197
Q

program design

A

monolith approach and dividing the problem approach

198
Q

monolith approach

A

everything is done in one main routine.

only use functions supplied by system.

199
Q

dividing the problem

A

two criteria : form, function

200
Q

dividing the problem : form

A

look at operations, think about the division of function based on branching

201
Q

dividing the problem : function

A

looks at operations and construct functions based on results

202
Q

dividing the problem : form advantages

A

easy to read and understand

203
Q

dividing the problem : form disadvantages

A

everything needs to be changed to change the I/O

204
Q

dividing the problem : function advantages

A

functions are light-weight and reusable

205
Q

dividing the problem : function disadvantages

A

functions do not handle I/O

206
Q

monolith approach : disadvantages

A
  • long and hard to read
  • can be repetitions of previous code
  • hard to modify
207
Q

model-view-controller

A
  • software design-pattern used to develop user interfaces

- divides program into three interconnected elements

208
Q

model-view-controller : model

A

directly manages data, logic and rules of application

209
Q

model-view-controller : view

A

any representation of information

210
Q

model-view-controller : controller

A

accepts inputs and converts it to commands

211
Q

shell scripts : printing with echo

A

echo “ there are “ … “ files in directory “

212
Q

shell scripts : setting variables

A

A = 1, B = “text string”, C = $(date)

213
Q

shell scripts : using variables

A

echo “ A is $A “

214
Q

shell scripts : capturing output of commands

A

variable = &( … )

echo “$variable”

215
Q

shell scripts : arithmetic operations

A

$ (( expression ))

operations: +,-,*,/,%,++,–,**
ex. $ (( 20 + 5 ))

216
Q

shell scripts : command line parameters

A

parm1 = $1, parm2 = $2

ex. ./parms.sh one two

217
Q

shell scripts : functions

A
ex. function totalFiles{
            find $1 -typef | wc -l
      }
home = /home/debs/Programs
totalFiles $home
218
Q

shell scripts : comparisons

A

-lt, -gt, -eq, -ne, -le, -ge

219
Q

shell scripts : branching - if

A
if [ ... ]; then
     do this
elif [ ... ]; then
     do this
else
     do this
fi
220
Q

shell scripts : branching - for

A
FILES = "$@"
for f in $FILES
do
      do this
done
221
Q

shell scripts : branching - while

A
i = 0
while [ $i -le 4 ]
do
     do this
done
222
Q

1-D Array

A

datatype name [size]

223
Q

2-D Array

A

datatype name [size1] [size2]

int grid [3][4] = {
    {0,1,2,3},
    {1,3,5,7},
    {2,4,6,8},
};
224
Q

passing arrays to functions

A

1-D : pass by pointer
2-D : when both dimensions are macro
when 2nd dimension is macro
using a pointer when neither are macro
pointer : displayArray(&field[0][0], row, col );

225
Q

global scope variables

A
  • variables accessible from everywhere, are macro constants

- great for system functions

226
Q

local scope variables

A
  • variables inside function

- variables in functions can have the same name

227
Q

switch

A
  • test value of a variable and compares it with cases
  • when match is found, execute code; break statement will terminates switch
    ex. switch ( expression ){
    case 1:
    statements;
    break;
    default:
    statements;
    break;
    }
228
Q

maximal munch

A

compiler will bite off the one with largest sequence of char

ex. z = y+++x; == z = y++ + x;

229
Q

include “limits.h”

A

for integer limits: INT_MIN, UINT_MIN, LONG_MIN, ULONG_MIN

230
Q

include “values.h”

A

for float: FLT_MIN

for double: DBL_MIN

231
Q

static variables

A
  • some functions wont work because variables are only in scope of function
  • static variables, not stored in stack
    format: static datatype name = value;
232
Q

precedence

A

arithmetic, relational, logical

233
Q

bitwise operators

A
  • works on bits and performs bit-by-bit operators

includes: binary AND(&), binary OR( | ), binary(^)

234
Q

binary AND

A

copies a bit to result it both operands exist

235
Q

binary OR

A

if either operand exists

236
Q

binary XOR

A

if only one exists

237
Q

shift operators

A

to left (<>#)

238
Q

conditional operator

A

returns a value when true, and another when false

ex. (A>100? 0 : 1 );

239
Q

random( )

A
  • function that uses a non-linear additive feedback random number generator
  • default table size of 31 long integers in range from 0 to RAND_MAX
  • period of generation 16^((2^31)-1)
240
Q

srandom( )

A
  • function sets its arguments as the seed for a new sequence of random integers to be returned by random()
  • if no seed –> uses seed with a value of 1
241
Q

file modes : r+

A

open existing file for reading and writing; start at the beginning

242
Q

file modes : w+

A

create new file for reading and writing; start at the beginning; truncates existing file

243
Q

file modes : a+

A

open existing file for reading and writing; write to the end of the file