Data structure using C
Dr. Amit J. Chinchawade
PhD ( Electronics & Communication)
Department of Electronics & Computer,
Sharad Institute of Technology College of Engineering , Yadrav
C is a procedural programming language known for its simplicity and
flexibility. Its basic structure consists of a set of elements and syntax rules
that we need to follow when writing C programs.
1. Comments:
Comments are used to provide information about the code but are ignored
by the compiler. In C, comments can be single-line comments (starting
with `//`) or multi-line comments (enclosed within `/*` and `*/`).
// This is a single-line comment
/*
This is a
multi-line comment
*/
2. **Preprocessor Directives**:
Preprocessor directives start with a `#` symbol and are used to include
header files, define macros, and perform other preprocessing tasks.
Common directives include `#include` for including header files and
`#define` for defining macros.
#include <stdio.h>
#define PI 3.14159
3. **Main Function**:
Every C program must have a `main` function. Execution of the program
begins with the `main` function.
int main() {
// Your code here
return 0;
}
4. **Data Types**:
C supports various data types such as `int`, `float`, `char`, etc. You use
these to declare variables.
int age;
float price;
char grade;
5. **Variable Declarations**:
Variables are declared before they are used. You specify the data type and
the variable name.
int x, y;
6. **Statements and Expressions**:
C programs consist of statements and expressions that perform actions or
calculations. Statements typically end with a semicolon `;`.
x = 10;
y = x + 5;
7. **Functions**:
You can define your own functions, in addition to `main`, to break the
program into smaller, manageable parts.
int add(int a, int b) {
return a + b;
}
8. **Control Structures**:
C provides control structures such as `if`, `else`, `while`, `for`, etc., to
control the flow of your program.
if (x > 0) {
printf("x is positiven");
} else {
printf("x is non-positiven");
}
while (y < 100) {
// Loop body
}
for (int i = 0; i < 5; i++) {
// Loop body
}
9. **I/O Functions**:
C provides functions like `printf` and `scanf` for input and output
operations.
printf("Enter your age: ");
scanf("%d", &age);
10. **Libraries**:
You can use functions from standard libraries by including the appropriate
header files and linking with the necessary libraries.
#include <stdio.h> // Standard I/O library
#include <math.h> // Math library
11. **Return Statement**:
The `main` function typically ends with a `return` statement, indicating the
program's exit status (0 typically means successful execution).
return 0;

Data Structure Using C.pptx

  • 1.
    Data structure usingC Dr. Amit J. Chinchawade PhD ( Electronics & Communication) Department of Electronics & Computer, Sharad Institute of Technology College of Engineering , Yadrav
  • 2.
    C is aprocedural programming language known for its simplicity and flexibility. Its basic structure consists of a set of elements and syntax rules that we need to follow when writing C programs.
  • 3.
    1. Comments: Comments areused to provide information about the code but are ignored by the compiler. In C, comments can be single-line comments (starting with `//`) or multi-line comments (enclosed within `/*` and `*/`). // This is a single-line comment /* This is a multi-line comment */
  • 4.
    2. **Preprocessor Directives**: Preprocessordirectives start with a `#` symbol and are used to include header files, define macros, and perform other preprocessing tasks. Common directives include `#include` for including header files and `#define` for defining macros. #include <stdio.h> #define PI 3.14159
  • 5.
    3. **Main Function**: EveryC program must have a `main` function. Execution of the program begins with the `main` function. int main() { // Your code here return 0; }
  • 6.
    4. **Data Types**: Csupports various data types such as `int`, `float`, `char`, etc. You use these to declare variables. int age; float price; char grade;
  • 7.
    5. **Variable Declarations**: Variablesare declared before they are used. You specify the data type and the variable name. int x, y;
  • 8.
    6. **Statements andExpressions**: C programs consist of statements and expressions that perform actions or calculations. Statements typically end with a semicolon `;`. x = 10; y = x + 5;
  • 9.
    7. **Functions**: You candefine your own functions, in addition to `main`, to break the program into smaller, manageable parts. int add(int a, int b) { return a + b; }
  • 10.
    8. **Control Structures**: Cprovides control structures such as `if`, `else`, `while`, `for`, etc., to control the flow of your program. if (x > 0) { printf("x is positiven"); } else { printf("x is non-positiven"); }
  • 11.
    while (y <100) { // Loop body } for (int i = 0; i < 5; i++) { // Loop body }
  • 12.
    9. **I/O Functions**: Cprovides functions like `printf` and `scanf` for input and output operations. printf("Enter your age: "); scanf("%d", &age);
  • 13.
    10. **Libraries**: You canuse functions from standard libraries by including the appropriate header files and linking with the necessary libraries. #include <stdio.h> // Standard I/O library #include <math.h> // Math library
  • 14.
    11. **Return Statement**: The`main` function typically ends with a `return` statement, indicating the program's exit status (0 typically means successful execution). return 0;