Since the late 19th century, C has been a popular programming language for general-purpose use.
Its applications are very diverse. It ranges from developing operating systems to databases and all.
Even if it’s old, it is still a very popular programming language.
As the whole UNIX operating system was
written in C, it has a strong association with the operating system C has also been used widely while creating iOS and Android kernels.
MySQL database is written using C.
Ruby and Pearl are mostly written using C.
Most part of Apache and NGINX is written using C.
Embedded Systems are created using C
Programming in C involves following a basic structure throughout. Heres what it can be broken down to.
#include <stdio.h>
int main()
{
return 0;
}
//This is a single line comment
/* This is a
multi-line
comment */
Data Type |
Size |
Description |
Format Specifier |
int |
2 or 4 bytes |
Stores whole numbers, without decimals |
%d or %i |
float |
4 bytes |
Stores fractional numbers, containing one or more decimals. Sufficient for storing 7 decimal digits |
%f |
double |
8 bytes |
Stores fractional numbers, containing one or more decimals. Sufficient for storing 15 decimal digits |
%lf |
char |
1 byte |
Stores a single character/letter/number, or ASCII values |
%c |
// Creating variables having different data types
int integer = 26;
float floating = 39.32;
char character = 'A';
// Printing variables with the help of their respective format specifiers
printf("%d\n", integer);
printf("%f\n", floating);
printf("%c\n", character);
const int MOD = 10000007;
Operator |
Description |
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
% |
Modulus |
Operator |
Description |
> |
Greater than |
< |
Less than |
>= |
Greater than or equal to |
<= |
Less than or equal to |
== |
Is equal to |
!= |
Is not equal to |
Operator |
Description |
&& |
AND Operator |
|| |
OR Operator |
! |
NOT Operator |
Operator |
Description |
& |
Bitwise AND |
| |
Bitwise OR |
^ |
Bitwise XOR |
~ |
Bitwise Complement |
>> |
Shift Right Operator |
<< |
Shift Left Operator |
Operator |
Description |
= |
It assigns the right side operand value to the left side operand. |
+= |
It adds the right operand to the left operand and assigns the result to the left operand. |
-= |
It subtracts the right operand from the left operand and assigns the result to the left operand. |
*= |
It multiplies the right operand with the left operand and assigns the result to the left operand. |
/= |
It divides the left operand with the right operand and assigns the result to the left operand. |