0% found this document useful (0 votes)
9 views4 pages

Basic Building Blocks Notes

The document outlines important topics related to C programming, including tokens, data types, variables, constants, and type conversion. It provides definitions and examples for each topic, along with sample multiple-choice questions and interview questions. Key concepts include the classification of tokens, basic data types like int and float, and the distinction between implicit and explicit type conversion.

Uploaded by

mk6510459
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Basic Building Blocks Notes

The document outlines important topics related to C programming, including tokens, data types, variables, constants, and type conversion. It provides definitions and examples for each topic, along with sample multiple-choice questions and interview questions. Key concepts include the classification of tokens, basic data types like int and float, and the distinction between implicit and explicit type conversion.

Uploaded by

mk6510459
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C NOTES - IMPORTANT TOPICS FOR INTERVIEW & EXAMS

1. C TOKENS

------------------

Tokens are the smallest individual units in a C program. These are:

- Keywords: Reserved words (e.g., int, return, if)

- Identifiers: Names given to variables, functions (e.g., total, sum)

- Constants: Fixed values (e.g., 10, 'A', 3.14)

- Strings: Sequence of characters (e.g., "Hello")

- Operators: Symbols that perform operations (e.g., +, -, *, /)

- Special Symbols: e.g., {}, (), [], ;, #

2. BASIC DATA TYPES IN C

------------------

- int: Used for integers (e.g., 1, -10)

- float: Used for single precision floating numbers (e.g., 3.14)

- double: Used for double precision floating numbers (e.g., 2.718281828)

- char: Used to store characters (e.g., 'A', 'z')

- void: Represents no value/return type

3. VARIABLES & KEYWORDS

------------------

Variables:

- A variable is a container to store data.

- Must begin with a letter or underscore (_), no special characters.

Example: int age = 25;


Keywords:

- Reserved words in C (cannot be used as variable names).

Examples: auto, break, case, char, const, continue, default, do, else, enum, extern, float, for, goto,

if, int, long, register, return, short, signed, sizeof, static, struct, switch, typedef, union, unsigned,

void, volatile, while.

4. CONSTANTS

------------------

Constants are fixed values that do not change during program execution.

Types:

- Integer constants (e.g., 100)

- Floating-point constants (e.g., 3.14)

- Character constants (e.g., 'A')

- String constants (e.g., "Hello")

Define constants using:

#define PI 3.14

or

const float pi = 3.14;

5. TYPE CONVERSION & TYPE CASTING

------------------

Type Conversion:

- Implicit (automatic): Done by the compiler.

Example: int x = 10; float y = x + 2.5;

- Explicit (type casting): Done manually by programmer.


Syntax: (data_type) variable

Example: float f = (float)5 / 2; // Output: 2.5

6. MCQs - SAMPLE QUESTIONS

------------------

Q1: Which of the following is not a valid C variable name?

a) int_number

b) 1number

c) number1

d) _number

Ans: b) 1number

Q2: What is the size of int in C (in most systems)?

a) 2 bytes

b) 4 bytes

c) 8 bytes

d) Depends on compiler

Ans: d) Depends on compiler

Q3: Which keyword is used to prevent modification of a variable?

a) immutable

b) fixed

c) constant

d) const
Ans: d) const

7. INTERVIEW QUESTIONS

------------------

- What are the different types of tokens in C?

- What is the difference between variable and constant?

- What are keywords? Can you use them as variable names?

- What is type casting? Give an example.

- Difference between implicit and explicit conversion.

- What are the basic data types supported by C?

You might also like