C Language Basic Fundamental
Discover C Language Fundamental Tools-from basic to advanced concepts. Learn how to write efficient and concise code, and start your journey in the field of programming world by learning the fundamental of C programming language.
Are you an aspiring programmer and looking forward to building your career in the field of software engineering? then i will recommend you to start your journey with the c language. Because it’s a simple and concise language and easy to study.
C programming language, developed by Dennis Ritchie in 1972 at Bell Labs, stands as one of the most influential programming languages in computer science history. C programming language is known for its efficiency, and versatility, and is considered as the foundation language for starting your career as a programmer.
Reading this article will help you master the C language and will help you to gain a deeper knowledge of computer architecture.
Key Takeaways
- Understanding the features and advantages of C programming Language.
- Learning about different Data types, preprocessor directives, and operators used in C.
- Understanding the basic syntax to write C programs.
Features Of C Programming
C Programming Language is loved by programmers across the world for doing low-level coding and embedded programming. Despite being one of the oldest programming languages, C programming language is still in use and is considered a foundational base of many other programming languages.
Some of the main and important features of the C programming Language:
- C Programming Language has inbuilt functions and operators that are used to solve complex virtual problems.
- C is the combination of low-level assembly language and high-level programming languages which can be used to write an application and interact with low-level system memory as well.
- C programming language is compatible with almost every Operating system and can be used on any device making it more flexible.
- Data types and operators present in the C programming Language make it more speedy than others.
- C programming language is easily extendable as we already know that C++ is nothing but an extended version of C.
- The libraries of this programming language support various functions and operators.
Preprocessor Directives
The preprocessor directives in the C programming language play an important role in code processing before compilation. Preprocessor Directives are basically initiated with a “#” Symbol.
C Programming Language handles directives such as ‘#include’ which is used to include header files, this is the first line of the code that generally contains a library name ending with “.h” function.
Some common examples of #include preprocessor is- #include<stdio.h>, #include<conio.h>.
Next in the list ‘#define’ for defining constants in the code, it helps in making the code reusable and readable, reducing code complexity. The common example of #define preprocessor is-
#define Fruit = Apple;
This will substitute the variable fruit with “apple” everywhere in the program and reduce the efforts of the programmer.
Main() Function
The Main() Function is considered an important function in the C programming language within which the content of the program or calculation will be written.
All the logic, calculations, and functions are written within the main function.
Get Prince kumar’s stories in your inbox
Join Medium for free to get updates from this writer.
Let us understand this function more clearly with an example given below-
#include<stdio.h>
int main(){
//Display a message using of printf
printf("Hellow World");
//Return 0 Indicates the existed function successfully execute
return 0;
}Data Types
The Data types in the C programming language are like containers that hold different kinds of information in them.
They tell the computer how to interpret and work with the data stored in variables.
For example, an integer data type is used for whole numbers, while a character data type is used for individual letters or symbols.
The table given below contains a list of all the data types and their uses in C programming language, read the table to understand it more clearly.
These data types mentioned above are examples of Primary data types used in C programming. Another type of Data type includes derived data types.
Derived data types are primitive data types that help in forming new data structures called arrays and functions. For example, an Array can contain a set of primitive data types like — int, char, float, etc.
Operators In C
In C programming, an operator is a symbol that is used to perform a specific operation on one or more operands. These operations can include arithmetic calculations, comparisons, logical evaluations, bitwise manipulations, and more.
Now, We will discuss each operator and its function in C programming language for your better understanding.
- Arithmetic Operators: It is used to perform arithmetic calculations which include Addition, Subtraction, Multiplication, Division, Modulus, etc.
- Relational Operators: this operator of C programming language is used to perform comparisons between two or more operands. This includes equal to, not equal to, Greater than, less than, etc.
- Logical Operator: This operator is used to perform logical functions on elements. Logical operators include functions like (And, Or, Not).
- And Operator — Returns true if both elements are true.
- OR Operator — Returns true if at least one element is true.
- NOT Operator — Returns true if both are false.
- Assignment Operator: It is used to Assign a value of the right operand to the left operand. A common example of an assignment operator is “=”.
- Increment and Decrement Operator: This operator is used to increase or decrease the value of the operand by 1. Increment operators are generally defined by “++” while decrement operators are defined by “–”.
- Conditional Operator: These operators in C programming Language give values based on conditional statements. Conditional operators are defined by if-else statements.
Loops In C Programming
In C programming, loops are basically used to repeat a block of code multiple times until a specific condition is met. The two main types of iteration loops that are used in C programming language include
- for loop- this loop is used when you know the exact number of iterations needed in the C Program.
//For Example
for (int i = 0; i < 5; i++){
printf(“Iteration %d\n”, i);
}
//In this example, i is initialized to 0, the loop continues as long as i is less than 5, and i is incremented by 1 in each iteration.- while loop- The While loop is used when the number of iterations are not known in advance and are particularly based on the condition.
//For Example:
int count = 0;
while (count < 3){
printf(“Count: %d\n”, count);
count++;
}
//In this example, Count is Initialized to 0, the loop continues to iterate as long as count is less than 3, and count is incremented by 1 in each iteration.Basic Program Of C language For Beginners
Now, we will see a basic program of C language and relate all the things learned above in this program this will help you to understand the topic more clearly.
//Preprocessor Directives
#include <stdio.h>
#include <conio.h>
int main(){
// using int data type for number
int number, factorial = 1;
// Scanf is used to take input from the user.
printf(“Enter a positive integer: “);
scanf(“%d”, &number);
// using conditions statement
if (number < 0){
printf(“Error: Factorial is not defined for negative numbers.\n”);
} else {
// Applying For loop for iteration.
for (int i = 1; i <= number; i++) {
factorial *= i; // Equivalent to factorial = factorial * i;
}
printf(“Factorial of %d is %d\n”, number, factorial);
}
return 0;
}This blog covered the basic fundamentals of the C language, providing a solid foundation for beginners. In upcoming posts, we will delve deeper into more advanced concepts and features of C, helping you to further enhance your programming skills and knowledge. Stay tuned for more insights and detailed explanations!






