0% found this document useful (0 votes)
11 views

C_Programming_Notes

C is a high-level programming language known for its simplicity, efficiency, and support for low-level memory access. It has advantages such as fast execution and portability, but lacks support for object-oriented programming and built-in exception handling. Key concepts in C include data types, variables, operators, control structures, functions, and memory management techniques.

Uploaded by

ishanguragain9
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)
11 views

C_Programming_Notes

C is a high-level programming language known for its simplicity, efficiency, and support for low-level memory access. It has advantages such as fast execution and portability, but lacks support for object-oriented programming and built-in exception handling. Key concepts in C include data types, variables, operators, control structures, functions, and memory management techniques.

Uploaded by

ishanguragain9
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
You are on page 1/ 9

1) What is C? Write its Features.

C is a general-purpose, high-level programming language developed by Dennis Ritchie in 1972.

Features:

- Simple and easy to learn.

- Fast and efficient.

- Portable.

- Structured language.

- Supports low-level memory access.

2) Advantages and Disadvantages of C

Advantages:

- Fast execution

- Portable code

- Strong standard library

- Structured and modular

- Widely used in system programming

Disadvantages:

- No support for OOP

- No built-in exception handling

- Manual memory management

- Less user-friendly

- Lacks runtime checking

3) What is a Data Type? Explain with Examples.

A data type defines the type of data a variable can hold.

Examples:
- int a = 10;

- float b = 3.14;

- char c = 'A';

- double d = 12.3456;

4) What is a Variable? Explain its Types.

A variable stores data values.

Types:

- Local Variable

- Global Variable

- Static Variable

- Automatic Variable

- External Variable

5) What is an Operator? Types and Examples.

An operator performs operations on variables.

Types:

- Arithmetic (+, -, *, /)

- Relational (==, !=, >, <)

- Logical (&&, ||, !)

- Assignment (=, +=, -=)

6) Control Structure: Break vs Continue

Break:

- Ends the loop

- Used in loops/switch

- Moves control outside loop


- Stops execution

- Example: if(i==5) break;

Continue:

- Skips current iteration

- Used in loops

- Jumps to loop condition

- Doesnt stop loop

- Example: if(i==5) continue;

7) Looping: While vs Do While

While Loop:

- Condition checked first

- May not execute

- Syntax: while(condition)

Do While Loop:

- Condition checked later

- Executes at least once

- Syntax: do { } while(condition);

8) Array and String Functions

Array: int arr[5] = {1,2,3,4,5};

String: char name[] = "John";

Functions:

- strlen(str)

- strcpy(dest, src)

- strcmp(s1, s2)

- strcat(s1, s2)
9) Functions: Features and Types

Function: block of code for a task.

Features:

- Modularity, Reusable, Debuggable

Types:

- Library functions (printf)

- User-defined

10) Recursion Technique

Function calling itself.

Example:

int factorial(int n) {

if(n == 0) return 1;

return n * factorial(n - 1);

11) Auto vs External Storage

Auto:

- Default for local vars

- Created at function start

- No keyword

- Limited scope

- Fast

External:

- For global vars

- Exists throughout
- Uses extern

- Global access

- Slower

12) Structure with Example

Structure: groups different data types.

Example:

struct Student {

int id;

char name[20];

float marks;

};

13) Array vs Structure

Array:

- Same data type

- Access by index

- Contiguous memory

- Simple use

- Large data sets

Structure:

- Mixed data types

- Dot operator

- Varied memory

- Flexible

- Record storage
14) Structure vs Union

Structure:

- Separate memory

- Memory = sum of members

- Multi-value store

- Slower

- struct Student

Union:

- Shared memory

- Memory = largest member

- One value at a time

- Faster

- union Data

15) Array vs Pointer

Array:

- Fixed size

- Multiple elements

- Cannot reassign

- Static

- int arr[10];

Pointer:

- Dynamic memory

- Holds address

- Reassignable

- Flexible

- int *ptr;
16) Call by Value vs Call by Reference

Call by Value:

- Pass copy

- No original change

- Safe

- Slower

- func(a);

Call by Reference:

- Pass address

- Changes original

- Risky

- Faster

- func(&a);

17) Pointer with Example

Pointer stores address.

Example:

int a = 10;

int *p = &a;

printf("%d", *p);

18) Structure vs Pointer

Structure:

- Stores data

- Dot operator

- Multiple members
- Memory for data

- struct Student

Pointer:

- Stores address

- * and -> operators

- One variable

- Memory for address

- int *p;

19) Sequential vs Random Access

Sequential:

- In order

- Slower

- Simple

- Text files

- fgets()

Random:

- Direct access

- Faster

- Complex

- Databases

- fseek()

20) fprintf vs fscanf

fprintf():

- Write to file

- fprintf(fp, ...)
- Output

- Like printf

- Needs file pointer

fscanf():

- Read from file

- fscanf(fp, ...)

- Input

- Like scanf

- Needs file pointer

You might also like