100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Notas de lectura

Introduction to computer science 2 (csca48) notes + exercises + midterm

Puntuación
-
Vendido
-
Páginas
101
Subido en
21-08-2024
Escrito en
2024/2025

All notes from reading sections, lectures All exercises done Memory models examples Midterm reviews with answers Final exam review with answers All details

Institución
Grado












Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Estudio
Grado

Información del documento

Subido en
21 de agosto de 2024
Número de páginas
101
Escrito en
2024/2025
Tipo
Notas de lectura
Profesor(es)
Rawad
Contiene
Todas las clases

Temas

Vista previa del contenido

CSCA48"




duf

, Unit #1 -
Intro.doesn't have
interactive mode
needs compile :
for Syntax
code- code (also checks
~

empileid
/
: source


does something

human understandable P
-T imperative
I : step by Step-how program
High level understanding
:
simple : more focus on

[ EY
-




Low level
: machine
ciese language -

how computer works
-
need to know details
return o; successful running & # include stdio h
include and use code from
.




Libraries :
program can
23
Delimiters : code that belongs to a specific scope
'a' or
:

Comments in Al 11 e'$' or
in ar , void
:
or

Fundamental data types ,
floats double ,
: int

Variables are local t that function -




·
In : new line
Collection
GCC :
GNU compiler

file . - file- new
Specify Name :
gcc

quotes only
"
Use double
Errors
( missing ;I
Common :


of "I "

before return Is I instead
.




-

expected';" for itstype
constant too long
before string constant
char
-warning :
or ...
-

expected declaration specifers
I printf a fer ? %ht 3 . 145)
fr variables
,
:
p pointer
Format specifiers %C Char is string => 5 . 15

%f float
decimal 2 %at 5 1)
Yd sci notation
.

,
num using 14
floating point
= 3 .




% g
Control Sequences % print of
Common 1) print
It tab
In new line
while
il;3 for loop
updates printf("Yd"
Y
,

i readability
:
· Loops condition
for Lintialization ;
2) less code , less
For loops bugs
while loops
·
conditional Statements
if and else
( = , , >, =, =, !
operators
=


Comparison
·
88 !
Common
· logical Operators (11 ,




E
specify
decimal to 2 Check square approach
%. If :

one loop

func
-




·

Running : -iss
guare
x-wall-sta 199-file -oname .
- nested loop
= .




g break ;
-

while loop

on
laptop

,Un -
Model Runs

squarell gets
in
AM
erased

TerTeddy
Note :
<int square()
int square (intx]3 main -2)
.




Fi
m
-
= I

⑮put Geturr E




↑·
E
int si put -


S =


return s;
X D
xi
E into Lint
(local var)



int main()S
int input ; Global
int output;
in put = 7 ;

output =
square(inputt ; 3
the value for arguments
-
pass
by value making : a
copy of input
- -


Scope where variable can be referenced and manipulated
local variable scope
:


(input para and
-




variable between curly brackets
Local variable :



(difficult to debug
-




Global variable : can be used by all functions .




·
-




E [
int Xa 114 in y
=
113 - Note :


int square (15 25 3/n
-




Passing array
or pointer
X= X * X; 3 [int >
don't
main()E < global >
to function , you
a
int
are fixed .
need to reassign them
59 Data types
1 =




square) ; 3



as they are references
.

~
O X 2
.



g
-
reverse (array)
-




Type casting "
I 5/2 reversecarray X
=
result array =
int y: X ,
=
2 asint (x , y)
float result : 5
0 as float
result
enough) to get :So
=
2
Gresult
.



is
X/y ; =

[int] Lints <float > cast float() Cone
X = 5 % you can type
y
=
29
int
210] ;
-read and store values array
IOD
Array e
g
.
:
-




- non-extendable T


O to 1
n
type
-



same
-




-
all entries must have
NO WARNING for outside indexing
=
-




string
: char sing[1020]
tri :
end oftring deliminator
-




string [O] 'It's :
strings are properly terminated
compiler adds it to ensure
string [1] 10:
=


OR USE



J
# include <string he (variable "Store this") ;
eg strcpy
.




string
,


intialize a
Strcpyc
· :

strcat(variable, "also this") ;
result :



str cat)) concatenate strings e g alsothis
.
.


:
·
printf("s" variable); > store this
,


· strlen() : len of a string egstulen (var) ;
equal stremp (varl varz) ;
strings and returns if e.g ,
·
strempC :
compares 2 o
if var1 < var2 then - -

- Pointer : variable that contains memory address
.
if var 1 .
) var 2 then - +
= = var2
-
> 0
address of if vari
-
S :
get memory
intialize pointera contents of
-intap; dereference a pointer dereference
and change
&:

address (1)
then
- * (-- p) = 12 ; change memory
value
-
var =
Ap ; var stores p's

, Unit #2

declare
van is 18
My int
-address of int s
1 15
de referencing My
int is 21
My




1
m
Note :




Imp things to remember
① Always NULL
set pointer =



NULL
Check
② if pointer is
will crash
or
program
data from
Make sure accessing

Q ⑤ P index
.
pointers is within
# Arrays are passed as pointers
.
↑3 I %
NOLL


int > int >
L Listin




Set second of to 10
entry array

Main

(p + 1) = 10 %


prese
o
g
_




-
-
compiler



Exercises
.

Ex 1 Reverse string #define MAX 1027 int main()




I
word [MAX] ;
void reverse (char word(s) char

Stropy (word , "Joe") ;
int length strenword
=




(word) ; them
for (inti = 0 ; i < length/2 ; it s reverse / for arrays you don't reassign
11 word reverse (word) ; is wrong
.
char temp word[i] ;
e
g
.


=




word[i] =
word length-i-I ;
word[length 1-i] = temp
;
-




Ex Takes array , query target chars and replaces query
, w
targetchar
void replace (char word [] , char query , char targets

intlenstenworda
if(word (i) ==
query)3
word[i] =
targets
3
$50.49
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
khadijanoor

Conoce al vendedor

Seller avatar
khadijanoor University of Toronto
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
0
Miembro desde
1 año
Número de seguidores
0
Documentos
1
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes