Basic Introduction to C Programming language 2023-2024
Introduction to C Programming language 2023-2024 Welcome to your ultimate guide for BCA 1st Year students! In this website, we unravel the intricate world of C Programming Language, providing step-by-step explanations that make even the most complex concepts easy to understand. Whether you’re a beginner or looking to solidify your knowledge, join us to excel in your academic journey
UNIT 1
C Programming Language
- C language is a programming language which is very powerful and versatile. It was developed by Dennis Ritchie in 1972, and many software and applications are still made from it today.
- C language is a high-level language, through which we give instructions to computers. In this we write programs, which we can convert into machine-readable code with the help of compilers. The syntax of C language is very simple and straightforward, which even beginners can understand easily.
- C is a programming language developed at AT & T’s Bell Laboratories of USA in 1972 by Dennis Ritchie
- C Programming language is a machine independent programming language that is mainly used to create many types of application
- Any programming language can be divided into two categories
- Problem oriented [High level language]
- Machine oriented [Middle level language]
- But C is considered as a Middle level Language
Important of C Programming Language
- Variables and Data Types: In C language we store data using variables. Mainly data types like integers, floats, characters, and arrays are available.
- Operators: In C language we can use arithmetic, assignment, logical, and comparison operators, through which we can do calculations and comparisons.
- Control Flow: In C language we can use if-else statements, loops (like for, while, do-while), and switch-case statements, through which we can control the program flow.
- Functions: In C language we can define functions, through which we can modularize the code and can reuse it.
Feature of C Program
- Portability: C language is platform-independent, that is, we can easily run C programs from one platform to another.
- Efficiency: C language programs are very efficient. This means we can use direct memory access and low-level programming techniques, which enhance performance.
- Flexibility: In C language we can write our programs in a very flexible way. In this we can implement complex logic using functions, loops, and conditional statements.
- Industry-wide Usage: C language is very popular and is widely used in the industry. Its reason is its speed, performance, and compatibility.
- Structure language
- General purpose language
- Limited no of keyword
- Fast
- Mid level language
- Simple and efficient
- There are 32 keywords in C language 27 keywords Dennis Ritchie and 5 keywords is edit by ANSI
Character Set
- It the C programming language the character set refers to a set of all the valid characters that we can use in the source program for forming words, expressions and number
- In C language we store characters in char data type. Char data type is 1 byte and stores the corresponding value of ASCII code.
- In C language we write characters in single quotes (‘ ‘). For example, by writing ‘A’ we are representing the character ‘A’.
- In C language we can perform various operations with characters. We can compare, concatenate, and manipulate characters.
- In C language we can handle strings along with characters. We store strings in character arrays. Each character is stored in an element of the array, and the end character of the string is ‘\0’ (null character).
- In C language we can also use some built-in functions for characters and strings, like strcmp() to compare strings and strcat() to concatenate strings
Types of Characters in C language
- Digits
- Alphabets
- Main characters
Read more- https://pencilchampions.com/environmental-study-unit-i-bca-first-semester-2023/
Token
- Token are the smallest unit of program we can define the token as the smallest individual element
- Program cannot be created without token
- Token is a very important concept in C language. When we write C code, we divide the code into tokens.
Types of Token
- Keywords: Reserved keywords are there in C language, like “if”, “for”, “while”, “int”, “char”, etc. We use these keywords for specific meanings in the code.
- Identifiers: Identifiers are the names of variables and functions. We use unique identifiers in our code so we can identify and access them. Identifiers begin with alphanumeric characters and underscores (_).
- Constants: Constants are fixed values which we use in code. Examples of constants include integer constants (like 5, -10), floating-point constants (like 3.14, -2.5), character constants (like ‘A’, ‘b’), and string constants (like “Hello, world!” ).
- Operators: Operators are used to perform mathematical and logical operations. Examples of operators include arithmetic operators (+, -, *, /), assignment operators (=), comparison operators (==, !=), and logical operators (&&, ||).
- Punctuation: Punctuation characters define the structure of the code. Examples of punctuation characters include braces ({, }), parentheses (), []), commas (,), and semicolons (;).
Keyword
- A keyword is a reserved word
- There are only 32 reserved word in the C Language
- There are some common keywords in C language which are reserved and represent specific meanings.
- These keywords are predefined and we use them in the code.
Some common C language keywords are:
- if: Used to define conditional statement. We check the condition in the if statement and according to it the code is executed.
- else: Used with if statement. When the condition of the if statement is false, then the else block is executed.
- for: Used to define the looping mechanism. We specify the initial value, condition, and increment/decrement in the for loop.
- while: Used to define the looping mechanism. We check the condition in the while loop and when the condition is true, then the loop is executed.
- Int: Integer is used to define data type. We declare variables as integers with the int keyword.
- char: Used to define character data type. With char keyword we declare variables for characters.
- float: Used to define floating-point data type. With float keyword we declare variables for decimal numbers.
- return: Used in functions. With the return keyword we return a value from the function.
Identifier
- An identifier is used for any variable , function ,data definition etc.
- In C language , and identifier is a combination of alpha , numeric characters
- Identifiers or symbols are the names you supply for variable, types, functions, and labels in your program.
- Identifiers identify our variables, functions, and user-defined names. We use them in the code so that we can refer to them. There are some rules for identifiers:
- Identifiers can begin with letters (both uppercase and lowercase), digits, and underscore (_).
- The first character must be a letter or underscore (_).
- Identifiers are case-sensitive, meaning uppercase and lowercase characters are treated differently.
- Keywords cannot be identifiers.
Constant
- Constant is an entity that refers to fixed values and it can not be changed
- In C language a number or character or string of characters is called a constant
Types of constant
- Integer Constants: Represent whole numbers, like 10, -5, 100.Floating-point
- Constants: Represent decimal numbers, such as 3.14, -0.5.
- Character Constants: Represent single characters, like ‘A’, ‘b’, ‘$’.
- String Constants: Represent multiple characters, like “Hello”, “World”.
Data type
- Data type is a type of data which is used in the program
- In other words we can say that it is used to declare a variable
- A data type specifies the type of data that a variable can store such as integer floating, character etc
Types of data type
- primary data types
- secondary data types
Variable
- Variables are very important in C language. Variables give us the flexibility to store and manipulate values.
- We represent a variable by the name of a memory location. Every variable has a data type, like int, float, char, etc. We use variables in the code so that we can refer to them and update their values.
- It is necessary to declare and initialize the variable. To declare we have to specify the data type and name of the variable. To initialize we assign a value to the variable.
Types of variable
- Static variable
- Local variable
- Global variable
- Extern variable
- Automatic variable
Comments
- Comments are non-executable statement but read ale by the compiler
- It is widely used for documenting the code
- A Comment use to explain or mention something in code
Types of comments
- Single line comment = //
- Multiple line comment = /*->*/
Discover more from
Subscribe to get the latest posts sent to your email.