PDF Notes: UNIT-1,2&3 Theory

    Master this deck with 20 terms through effective study methods.

    Generated from uploaded pdf

    Created by @Pride

    What are the primary data types in C and their uses?

    The primary data types in C include 'int' for integers (whole numbers), 'float' for single-precision floating-point numbers (decimal values), and 'char' for characters. These data types define the type of data that a variable can hold.

    How do you declare a variable in C?

    To declare a variable in C, you use the syntax: data_type variable_name; For example, 'int age;' declares a variable named 'age' of type integer.

    What is the significance of keywords in C?

    Keywords in C are reserved words with predefined meanings that cannot be used for other purposes. Examples include 'int', 'char', 'if', 'else', 'for', and 'while'. They are essential for defining the structure and control flow of a program.

    What rules must identifiers follow in C?

    Identifiers in C must start with a letter (uppercase or lowercase) or an underscore. They can contain letters, digits, and underscores but cannot contain spaces or special symbols. Identifiers are case-sensitive and cannot be keywords.

    What is the purpose of the 'const' keyword in variable declaration?

    The 'const' keyword is used to declare a variable as constant, meaning its value cannot be altered after initialization. For example, 'const int max_score = 100;' defines 'max_score' as a constant integer.

    How can multiple variables be declared in a single line in C?

    In C, multiple variables can be declared in a single line by separating them with commas. For example, 'int x = 10, y = 20, z = 30;' declares three integer variables 'x', 'y', and 'z' with their respective initial values.

    What are symbolic constants and how are they defined in C?

    Symbolic constants are defined using the '#define' directive, allowing you to create constants without a data type. For example, '#define PI 3.14159' substitutes 'PI' with '3.14159' wherever it appears in the code, improving readability.

    What are the different classifications of operators in C?

    Operators in C are classified into several categories, including arithmetic operators (for mathematical operations), relational operators (for comparisons), logical operators (for logical operations), and bitwise operators (for bit manipulation).

    What is the character set in C and what does it include?

    The character set in C includes all characters that can be used in the language, comprising uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), special characters (e.g., +, -, *, /), and whitespace (spaces, tabs, newlines).

    What are tokens in C and what types exist?

    Tokens are the smallest units of a C program and include keywords (reserved words), identifiers (names for variables/functions), constants (fixed values), operators (symbols for operations), and separators/punctuation (symbols like ;, ,, {}).

    How do you assign values to variables in C?

    Values can be assigned to variables during declaration or after declaration. For example, during declaration: 'int age = 25;' or after declaration: 'int age; age = 25;'.

    What is the difference between a keyword and an identifier in C?

    A keyword is a reserved word in C with a predefined meaning that cannot be used for other purposes, while an identifier is a name created by the programmer for variables, functions, or arrays, following specific naming rules.

    Why is it important to follow naming conventions for identifiers in C?

    Following naming conventions for identifiers in C is important for code readability, maintainability, and to avoid conflicts with keywords. Proper naming helps other programmers understand the purpose of variables and functions.

    What are the implications of using case sensitivity in identifiers?

    C is case-sensitive, meaning 'Variable' and 'variable' are considered different identifiers. This can lead to confusion if not managed properly, so it's important to maintain consistent naming conventions.

    How does the use of whitespace affect C code?

    Whitespace in C, including spaces, tabs, and newline characters, is used to separate tokens in the code. While it does not affect the execution of the program, it is crucial for improving code readability.

    What are arithmetic operators in C and give examples?

    Arithmetic operators in C perform basic mathematical operations. Examples include '+', '-', '*', '/', and '%'. These operators are used to perform calculations on numeric data types.

    What is the role of decision-making points in C programming?

    Decision-making points in C programming, represented by constructs like 'if', 'else', and 'switch', allow the program to branch based on conditions, enabling dynamic control flow.

    How can you improve code readability using symbolic constants?

    Using symbolic constants improves code readability by providing meaningful names for fixed values, making the code easier to understand and maintain. If a value needs to change, it can be updated in one place.

    What is the significance of the #define directive in C?

    The #define directive in C is used to create symbolic constants and macros. It allows for the substitution of a name with a value or expression throughout the code, enhancing flexibility and maintainability.

    What are the potential pitfalls of not following C's naming conventions?

    Not following C's naming conventions can lead to code that is difficult to read and maintain, increased likelihood of naming conflicts with keywords, and confusion among programmers regarding the purpose of variables and functions.