Introduction to C Programming
- 44Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What was the purpose of Scratch in CS50's week zero?
Scratch aimed to make programming accessible and user-friendly, and to introduce fundamental concepts like functions, conditionals, loops, and variables visually.
Or swipe the card
44 cards
What was the purpose of Scratch in CS50's week zero?
Scratch aimed to make programming accessible and user-friendly, and to introduce fundamental concepts like functions, conditionals, loops, and variables visually.
How does the 'when green flag clicked' block in Scratch translate to C code?
The 'when green flag clicked' block in Scratch is equivalent to the
int main(void)function in C.What does the purple 'say' block in Scratch represent in C?
The purple 'say' block in Scratch is analogous to the
printffunction in C.What is 'source code' in programming?
Source code is human-readable code written by programmers in a language like C that resembles English but has specific patterns and syntax.
Why can't computers directly understand source code?
Computers can only understand 'machine code', which consists of binary zeros and ones.
What is the role of a 'compiler' in programming?
A compiler is a special program that translates human-written source code (like C) into machine code (zeros and ones) that a computer can understand and execute.
What is VS Code, and what is its purpose in CS50?
VS Code (Visual Studio Code) is a popular, industry-standard programming environment used for writing code. In CS50, a cloud-based version (cs50.dev) is provided with pre-installed useful software.
What is a 'graphical user interface' (GUI) and a 'command-line interface' (CLI)?
A GUI (Graphical User Interface) uses buttons, icons, and menus (like VS Code's visual elements), while a CLI (Command-Line Interface) requires typing commands into a terminal window (like
makeorls).What is the file extension convention for C source code files?
C source code files are conventionally named with a
.cfile extension (e.g.,hello.c).What are the three essential steps to compile and run a C program in the CS50 environment using the command line?
- Create the source code file (e.g.,
code hello.c). 2. Compile the source code into machine code (make hello). 3. Execute the machine code (./hello).
- Create the source code file (e.g.,
What is the significance of the
makecommand in the CS50 environment?The
makecommand acts as a trigger for the compiler, translating source code (e.g.,hello.c) into machine code (e.g.,hello).What does
./hellomean when typed in the terminal?. / hellomeans 'run the program namedhellolocated in the current directory (represented by.).'What is the purpose of a 'semicolon' in C?
A semicolon (
;) is used to finish a thought or statement in C, signaling to the compiler that a line of code is complete.What is an 'escape sequence' in C, and what does
\nrepresent?An escape sequence is a combination of characters used to represent special characters in a string.
\nrepresents a 'new line' character, similar to hitting Enter.How do you include a literal double quote
"or a literal backslash\\within aprintfstring in C?To include a literal double quote, use
\". To include a literal backslash, use\\.What is a 'header file' in C, and why is
stdio.hincluded?A header file (ending in
.h) contains declarations for functions and definitions that a programmer can use.stdio.h(Standard Input/Output) is included to access functions likeprintf.What is a 'library' in programming?
A library is a collection of pre-written code that someone else developed, offering ready-to-use functionality that programmers can include in their own programs.
What are 'man pages' or 'manual pages' in C programming?
Manual pages (or 'man pages') are documentation for C functions and libraries, providing instructions on how to use them. CS50 offers a more user-friendly version at
manual.cs50.io.What is the purpose of
cs50.hin CS50 programs?cs50.his a custom CS50 header file that provides simpler functions, likeget_stringandget_int, to facilitate user input in C during early weeks.What is a 'return value' of a function?
A return value is a value (like text, an integer, or other data) that a function computes and 'hands back' to the part of the code that called it.
How do you store the 'return value' of a function in C?
You store a return value by assigning it to a 'variable' on the left-hand side of an assignment operator (
=). You must also specify the variable's 'type' (e.g.,string answer = get_string("What's your name?");).What are the common command-line commands for file and directory manipulation?
Common commands include:
ls(list files),cd(change directory),cp(copy file/folder),mkdir(make directory),mv(move/rename file/folder),rm(remove file), andrmdir(remove directory).What does
.(single dot) and..(double dot) represent in command-line paths?.refers to the 'current directory', and..refers to the 'parent directory' (the folder containing the current one).What are different 'data types' in C for storing various kinds of data?
Common data types in C include:
string(text),int(integer),char(single character),double(real number with decimal),float(single-precision real number), andlong(larger integer).What are 'format codes' used for in C's
printffunction when printing different data types?%sis for strings,%iis for integers, and%fis for floating-point numbers (doubles/floats).How do you check for 'equality' between two values in C?
You use the 'double equal sign' (
==) to check for equality. A single equal sign (=) is used for assignment.What is the operator for 'not equals' in C?
The operator for 'not equals' is
!=(exclamation point followed by an equal sign).What is the most 'conventional' way to initialize and increment a counter variable in a C loop?
Conventionally, a counter variable (
i) is initialized to 0, checked against a 'less than' condition (e.g.,i < 3), and incremented usingi++.What is the purpose of indentation and whitespace in C code?
Indentation and whitespace improve code 'readability' and 'style', making it easier for humans to understand the code's structure and logic.
What is
style50in the CS50 environment?style50is a CS50 tool that provides suggestions on how to improve the 'style' of your C code to align with standard programming conventions.What is
check50in the CS50 environment?check50is a command-line tool that evaluates the 'correctness' of your C code by running tests against it to identify bugs or logical errors.What is
design50in the CS50 environment?design50is a CS50 tool (represented by the Duck chatbot) that offers qualitative advice on how to improve the 'design' of your C code, beyond just correctness and style.What is a 'magic number' in programming, and why should it generally be avoided?
A 'magic number' is a literal numerical value that appears directly in code without explanation. It should be avoided because it makes code less readable and harder to maintain.
How do you declare a 'constant' variable in C?
You use the
constkeyword before the data type (e.g.,const int N = 3;).What are 'comments' in C code, and how are they written?
Comments are notes within the code intended for human readers, ignored by the compiler. Single-line comments start with
//, and multi-line comments are enclosed by/*and*/.What is 'integer overflow' in C?
Integer overflow occurs when an integer variable attempts to store a number larger than its maximum capacity, causing it to 'wrap around' to a negative number or zero.
What is 'truncation' when performing division with integers in C?
Truncation occurs when an integer divided by an integer results in a real number, but the decimal part is simply discarded, yielding only the whole-number portion (e.g.,
1 / 3becomes0,3 / 2becomes1).How can you get a floating-point result from integer division in C?
You can 'cast' one or both of the integer operands to a
floatordoubletype before performing the division (e.g.,(float)x / yor(double)x / y).What is 'floating-point imprecision' in C?
Floating-point imprecision refers to the inability of computers to represent all real numbers (numbers with decimal points) perfectly accurately due to using a finite number of bits.
What is the 'scope' of a variable in C?
The scope of a variable determines where in the code it can be accessed. Generally, variables only exist and are usable within the curly braces (
{}) where they are defined.What is a 'prototype' of a function in C, and why is it necessary sometimes?
A function prototype is the first line of a function's definition (return type, name, and parameters) followed by a semicolon. It's necessary when a function is called before its full definition appears in the code.
What does
voidmean when used as a function's return type or in its parameter list in C?voidas a return type means the function does not return any value.voidin the parameter list means the function takes no arguments.What is the 'Y2K problem' and how does it relate to data type limitations?
The Y2K problem (Year 2000) was a concern that computer systems storing years as two digits (e.g., '99' for 1999) would incorrectly interpret the year 2000 as 1900 ('00'), leading to system failures.
What is the 'Unix Epoch' and the potential 'Year 2038 problem'?
The Unix Epoch is the point in time (January 1, 1970, 00:00:00 UTC) from which many computer systems measure time as a 32-bit integer representing seconds. The Year 2038 problem is the anticipated overflow of this 32-bit integer, causing systems to misinterpret time.

Ask anything
We've read this whole study set, so questions about it get the best answers.