KEMBAR78
C Language 1 | PDF | Data Type | Variable (Computer Science)
0% found this document useful (0 votes)
16 views5 pages

C Language 1

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)
16 views5 pages

C Language 1

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

C language

19 November 2023 00:38

C PROGRAMMING ROADMAP
1. Basics of C: Understand variables, data types, and operators.
2. Control Statements: Learn about decision-making and loops.
3. Functions: Understand built-in and user-defined functions.
4. Arrays and Strings: Learn to store and manipulate data.
5. Pointers: Understand how to use memory in a more flexible way.
6. Dynamic Memory Allocation: Learn about malloc, calloc, free,
realloc.
7. Structures and Unions: These are equivalent to objects in OOP.
8. File Handling: Learn to read, write, and manipulate files.

After this, work on projects to apply your skills. Don't forget to debug
your code often to understand your errors!

VARIABLES
In simple terms, variables in C are like containers where we store
data for use in our program. They have a type (like int, float, char
etc.) and a unique name. For example:

```c
int age = 20;
```

Here, 'age' is a variable of type 'int', and we're storing the number
'20' in it. "Syntax error" can occur if there's something wrong with
how you've written this line! When debugging the code, always
double-check your variables.

Float and char are two other important data types in C.

1. Float: It's used when you need to store decimal numbers (numbers
with fractional parts). For example:

```c
float weight = 72.5;
```

2. Char: It's used to store a single character. It could be a letter,


number, symbol, etc. For example:

```c
char initial = 'S';
```

Remember, each data type in C serves a specific purpose, so choose


them according to the kind of data you need to store. Keep
debugging the code to ensure you're using them correctly!

New Section 1 Page 1


debugging the code to ensure you're using them correctly!

For storing multiple characters, numbers, and symbols, you would


use a 'char array' or 'string'. Here's how you can do it in C:

```c
char name[] = "Sambit123!";
```

In this example, 'name' is a string that stores "Sambit123!"


, numbers, and symbols. Just remember, strings are just arrays of
characters in C. Keep it up, you're doing great!

DATA TYPES

C language mein kuch main data types hote hain:

1. Integers (int): Ye whole numbers store karne ke liye use hote hain, jaise 5, -3, 0, etc.

2. Floating point numbers (float): Ye decimal numbers store karne ke liye use hote hain,
jaise 3.14, -0.01, etc.

3. Characters (char): Ye single characters store karne ke liye use hote hain, jaise 'a', 'Z',
'1', etc.

4. Void: Ye special type hota hai jo 'no value' ya 'no type' indicate karta hai.

Inke alawa bhi kuch aur types hote hain jaise arrays, pointers, etc. Lekin ye basic types
hain jo sabse zyada use hote hain.

Aur haan, variables declare karne ke liye bhi hum inhi data types ka use karte hain. Jaise
ki, 'int num;' yahan 'num' ek variable hai jisme hum integer type ki value store kar sakte
hain. 'int a = 10;' yahan 'a' ek variable hai jiska data type 'int' hai.

OPERATIORS
C language mein humein kuch operators milte hain jo humein different types ke operations
karne mein help karte hain:

1. Arithmetic Operators: Ye basic math operations ke liye hote hain, jaise ki addition (+),
subtraction (-), multiplication (*), division (/), aur modulus (% jo remainder deta hai division
ka).

2. Relational Operators: Ye do values ko compare karne ke liye hote hain. Jaise ki less than (<),
greater than (>), equal to (==), not equal to (!=), less than or equal to (<=), aur greater than or
equal to (>=).

3. Logical Operators: Ye logical AND (&&), OR (||), aur NOT (!) operations ke liye hote hain.

Inhe samajhne ke liye practice karne ki zarurat hoti hai. Koi bhi programming concept ko
samajhne mein thoda samay lagta hai.

ARITHMETIC OPERATORS
New Section 1 Page 2
ARITHMETIC OPERATORS
Yahan kuch basic examples hain arithmetic operators ke:

1. Addition (+):
```c
int a = 5;
int b = 10;
int sum = a + b; // sum will be 15
```

2. Subtraction (-):
```c
int a = 20;
int b = 10;
int diff = a - b; // diff will be 10
```

3. Multiplication (*):
```c
int a = 4;
int b = 5;
int product = a * b; // product will be 20
```

4. Division (/):
```c
int a = 20;
int b = 5;
int quotient = a / b; // quotient will be 4
```

5. Modulus (%):
```c
int a = 22;
int b = 5;
int remainder = a % b; // remainder will be 2
```

Ye examples aapko samajhne mein help karenge ki kaise arithmetic operators ka use hota hai
C language mein.
Sambit, yahan "sum, diff, product, quotient, remainder" variables hain jo humne banaye hain.
Inka matlab hai:

- "sum": Yeh variable humne 'a' aur 'b' ka addition store karne ke liye banaya hai.
- "diff": Yeh 'a' se 'b' subtract karne ka result store kar raha hai.
- "product": Yeh 'a' aur 'b' multiply karne ka result store kar raha hai.
- "quotient": Yeh 'a' ko 'b' se divide karne ka result store kar raha hai.
- "remainder": Yeh 'a' ko 'b' se divide karne ke baad jo remainder reh jaata hai, usko store kar
raha hai.
Aap in variables ke naam badal sakte hain. Bas dhyan rakhein ki aapne jo variable define kiya
hai, usi ka use karein. Jaise agar aap 'sum' ki jagah 'total' likhna chahte hain, toh aap kar sakte
hain. Bas code mein har jagah 'sum' ki jagah 'total' use karna hoga. Code likhte waqt
consistency bahut zaroori hai.

RELATIONAL OPERATORS

New Section 1 Page 3


C language mein relational operators ka use hum conditions check karne ke liye karte hain. Ye
hain kuch examples:

```c
int a = 10, b = 20;

// Checking if a is less than b


if(a < b) {
printf("a is less than b\n");
}

// Checking if a is greater than b


if(a > b) {
printf("a is greater than b\n");
}

// Checking if a is equal to b
if(a == b) {
printf("a is equal to b\n");
}

// Checking if a is not equal to b


if(a != b) {
printf("a is not equal to b\n");
}

// Checking if a is less than or equal to b


if(a <= b) {
printf("a is less than or equal to b\n");
}

// Checking if a is greater than or equal to b


if(a >= b) {
printf("a is greater than or equal to b\n");
}
```

LOGICAL OPERATORS
Bilkul, Sambit! C language mein hum 3 prakar ke logical operators ka use karte hain: AND
(&&), OR (||), aur NOT (!). Ye hain kuch examples:

```c
int a = 10, b = 20, c = 30;

// Logical AND example


if(a < b && b < c) {
printf("Both conditions are true\n");
}

// Logical OR example
if(a < b || a > c) {
printf("At least one condition is true\n");
}

// Logical NOT example

New Section 1 Page 4


// Logical NOT example
if(!(a > b)) {
printf("a is not greater than b\n");
}
```

New Section 1 Page 5

You might also like