0% found this document useful (0 votes)
2 views2 pages

C Programming Basics and Examples

The document provides an introduction to C programming, covering its basic structure, including preprocessor directives, the main function, and return statements. It discusses variables and common data types such as int, float, char, and double, along with examples. Additionally, it outlines various operators in C, including arithmetic, relational, logical, bitwise, assignment, and increment/decrement operators.

Uploaded by

aiyshahiba
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)
2 views2 pages

C Programming Basics and Examples

The document provides an introduction to C programming, covering its basic structure, including preprocessor directives, the main function, and return statements. It discusses variables and common data types such as int, float, char, and double, along with examples. Additionally, it outlines various operators in C, including arithmetic, relational, logical, bitwise, assignment, and increment/decrement operators.

Uploaded by

aiyshahiba
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 Programming Notes

Day 1: Introduction to C

C is a powerful general-purpose programming language. It is used for system programming, game


development,
and software applications.

Basic Structure of a C Program:


1. Preprocessor Directives (#include <stdio.h>)
2. Main Function (int main())
3. Statements inside { }
4. Return Statement (return 0;)

Example:
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}

Day 2: Variables and Data Types

Variables store data in memory. Each variable has a data type.

Common Data Types:


- int (Integer) -> Example: int a = 5;
- float (Decimal) -> Example: float pi = 3.14;
- char (Character) -> Example: char letter = 'A';
- double (Large Decimal) -> Example: double num = 10.234;

Example:
#include <stdio.h>
int main() {
int num = 10;
float pi = 3.14;
printf("%d %f", num, pi);
return 0;
}

Day 3: Operators in C

Operators are symbols that perform operations on variables.

1. Arithmetic Operators: +, -, *, /, %
2. Relational Operators: ==, !=, >, <, >=, <=
3. Logical Operators: &&, ||, !
4. Bitwise Operators: &, |, ^, ~, <<, >>
5. Assignment Operators: =, +=, -=, *=, /=, %=
6. Increment & Decrement: ++, --

Example:
#include <stdio.h>
int main() {
int a = 5, b = 3;
printf("%d", a + b); // Output: 8
return 0;
}

You might also like