Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 83 pages
Exam (elaborations)

CSE 2421 Midterm 1 Updated Study Guide Exam With Complete Solutions

Document preview thumbnail
Preview 4 out of 83 pages

CSE 2421 Midterm 1 Updated Study Guide Exam With Complete Solutions ...

Content preview

CSE 2421 Midterm 1 Updated Study Guide Exam With
Complete Solutions



Say we have a function void trystat(void){ int fade = 1; static int stay = 1; printf("fade = %d
and stay = %d\n", fade++, stay++); What will this print if it is called 3 times? - ANSWER fade

= 1 and stay = 1

fade = 1 and stay = 2

fade = 1 and stay = 3

Why does this happen?

Becuase stay is a STATIC variable so its value is stored in the heap and accessed from there! It
doesn't dissapear after each function call, like fade does!




Given the following code declared within a block:

char str[100] = "This is the time of your life!"

The string "This is the time of your life!" is stored in what type of memory? heap or stack? -
ANSWER STACK!




What would scanf look like to scan in a short variable like "short half;"? - ANSWER

scanf("%hd", &half);




If an array is declared long timer_value[100]; then what are the TWO ways we can pass in this
parameter to funcA(); so that it can modify these values? Should you pass in &timer_value? -
ANSWER 1) funcA(timer_value)

,2) funcA(&timer_value[0])




NO! You should not pass this in!




What is the data type of string from the following declaration?

char string[] = "Don't overthink it!"; - ANSWER A char pointer! (char *^)




Say we have #define PAGES 959. What does printf("%10d\n", PAGES); print? - ANSWER
_______959

(_ designates whitespace) Note how it prints out the whitespace! It is asking to produce a field
10 spaces wide and, as we can see, there are 7 blanks and three digits printed! If we added a
(-) before this, it would move the number part to the left and print 7 whitespaces after it!




If you get confused about syntax and are worried you aren't remembering it right, check the
rest of the test! With all the multiple choice questions, there is a very good chance there is an
example of code, like a declaration, that is provided for what you are trying to do - ANSWER

Prof. Jones mentioned this herself, probably for a good reason.




Say you have int x=30; in main, and then inside of a block, there is int x=100 and then x++; in
that block. What is the value of the x in main outside of the block by the end of main? -
ANSWER Still 30! It has never changed. The "int x = 100;" and its increment ONLY effects the
int x version that is in the block! It is technically a COMPLETELY SEPARATE variable!




What if, in main, you have x=30; then a while loop stating while(x++ < 33) { int x= 100; x++;}

,What is the value of x by the end of this? What x is the one being used to iterate the while

loop? - ANSWER 34! And the x from the OUTER BLOCk is the one who runs the while loop!




Where is dynamic memory stored? - ANSWER On the HEAP!




Say we have #define BLURB "Authentic!". What does printf(" [%24.5s]\n", BLURB); print? -
ANSWER [_________________Authe], note again how the (_) denotes whitespace

The .5 precision tells printf() to just print ONLY 5 CHARACTERS!




What things use little endian storage? - ANSWER Intel, including x86, and ARM processors.
Everything else (that she will ask us about) uses big endian




Say in main we have int repid; What is stored in repid? It is an automatic variable, so think
about what that means... - ANSWER WE DUNNO. Could be 0. Could be 123456789. Could be
888. It is given a value from the stack that we don't know. So, we should initialize it! This is
the messy table analogy Prof. Jones used!




Where is the memory that is allocoated by calloc() and malloc() stored? - ANSWER In the

HEAP!




Say a value in a conditional for a while(conditional) is evaluated to -5. Will this while loop run?

(while(-5))? - ANSWER YES! It will! The only time it won't is when the value is 0.

, What does the comma operator guarantee about an expression? What part of x = (y = 3, (z =
++y + 2) + 5) is evaluated first? - ANSWER That the left most part of the expression is
evaluated first! So, y=3 is the first part to be evaluated!




Say we have scanf("%5s %10s", name1, name2);

If we enter in "Portnesia Callowit", what will be stored in name1 and name2? - ANSWER name1
= "Porte" and name2 = "nsia". Why does this happen? Because the second input read in with
%s picks up where the first was left off, until it reaches a newline or the 10 character limit
specified!. It would work as intended with Jesse Jukes, for example.




What does printf() return? = - ANSWER The number of CHARACTERS printed! Or, if there is an
error, it returns a negative value!




Can a switch statement be used to switch based on string values in C? - ANSWER NO! The
case value must be UNIQUE and CONSTANT!




Slide decks 1-3 Review: - ANSWER Intro to C




What is Java compiled into? - ANSWER Byte code




What is C compiled into? - ANSWER Machine code




Differences between Java and c with objects/classes - ANSWER C does not have them

Document information

Uploaded on
December 15, 2025
Number of pages
83
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$22.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Zayla
3.4
(18)
Sold
134
Followers
13
Items
16870
Last sold
2 days ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions