0% found this document useful (0 votes)
19 views3 pages

Basics of C Language

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)
19 views3 pages

Basics of C Language

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/ 3

Basics of C Language

1. What is C?

- C is a procedural programming language developed by Dennis Ritchie in 1972 at Bell Labs.

- It is the foundation of many modern languages like C++, Java, and Python.

- Known for its speed, portability, and system-level programming.

2. Basic Structure of a C Program

#include <stdio.h>

int main() {

printf("Hello, World!");

return 0;

3. Key Concepts in C

- Variables and Data Types

int age = 21;

float height = 5.8;

char grade = 'A';

- Operators

Arithmetic: +, -, *, /, %

Relational: ==, !=, <, >, <=, >=

Logical: &&, ||, !

Assignment: =, +=, -=, etc.


- Control Statements

if, else if, else

switch

for, while, do-while

Example:

for(int i = 0; i < 5; i++) {

printf("%d\n", i);

- Functions

int add(int a, int b) {

return a + b;

- Arrays

int numbers[5] = {1, 2, 3, 4, 5};

- Pointers

int a = 10;

int *p = &a;

4. Input & Output

#include <stdio.h>

int main() {
int num;

printf("Enter a number: ");

scanf("%d", &num);

printf("You entered: %d", num);

return 0;

5. Important Header Files

- <stdio.h> : Input/Output functions

- <stdlib.h> : Memory allocation, process control

- <string.h> : String handling

- <math.h> : Math functions

6. Compilation Process

- Write Code -> Save with .c -> Compile -> Run

- Compiler: gcc

gcc program.c -o program

./program

You might also like