Test 1 Review.docx
Document Details
Tags
Full Transcript
**Test 1 Review: Chapter 1, 2, 3.** **[Comments /\* and \*/ and //]** \* Know the difference between block style comments and single line comments. **- Single-Line Comments**: // \- Everything after // on that line is treated as a comment. -Can only occupy one line, used for brief notes.\ Ex: i...
**Test 1 Review: Chapter 1, 2, 3.** **[Comments /\* and \*/ and //]** \* Know the difference between block style comments and single line comments. **- Single-Line Comments**: // \- Everything after // on that line is treated as a comment. -Can only occupy one line, used for brief notes.\ Ex: int x = 5; // This is a single-line comment. **-Block(Multi-Line) Comments:** use /\* to start \*/ to end a block comment. -Comment can span multiple lines, and everything between /\* and \*/ is treated as a comment. -Can have multiple lines, used for longer explanations. Ex: /\* This is a block comment. It can spam multiple lines. \*/ Int y = 10 ; **[\#include , printf(), scanf()]** \* Know what the \#include preprocessor directive does and why it is required. The \#include preprocessor directive in C is used to include the contents of one file within another during the compilation process. **Purpose:** - **File Inclusion:** It allows you to incorporate the contents of header files, which often contain declarations for functions, macros, constants, and types that you want to use in your code. - **Code Reusability:** By including common libraries or custom headers, you can reuse code without rewriting it, promoting modular programming. - **Separation of Concerns:** It helps organize code by separating declarations from implementations, making programs easier to manage and understand. - **Function Declarations**: To use functions from libraries (like printf from stdio.h), you need their declarations, which are provided in the respective header files. - **Type Definitions:** Many libraries define types (like FILE in stdio.h), which are necessary for the proper use of functions. - **Preprocessor Behavior:** The \#include directive is processed by the preprocessor before the actual compilation, ensuring that all necessary definitions and declarations are available to the compiler.