C Programming Language
The C Language is developed by Dennis Ritchie for creating system applications that directly interact with the hardware devices such as drivers, kernels, etc.
C programming is considered as the base for other programming languages, that is why it is known as mother language.
It can be defined by the following ways:
Pause
Next
Mute
Current Time
0:39
/
Duration
18:10
Fullscreen
Mother language
System programming language
Procedure-oriented programming language
Structured programming language
Mid-level programming language
1) C as a mother language
C language is considered as the mother language of all the modern programming languages because most of the compilers, JVMs, Kernels, etc. are written in C language, and most of the programming languages follow C syntax, for example, C++, Java, C#, etc.

It provides the core concepts like the array, strings, functions, file handling, etc. that are being used in many languages like C++, Java, C#, etc.
Visit https://techzone360.shop/c-programming-language-tutorial/
2) C as a system programming language
A system programming language is used to create system software. C language is a system programming language because it can be used to do low-level programming (for example driver and kernel). It is generally used to create hardware devices, OS, drivers, kernels, etc. For example, Linux kernel is written in C.
It can’t be used for internet programming like Java, .Net, PHP, etc.
3) C as a procedural language
A procedure is known as a function, method, routine, subroutine, etc. A procedural language specifies a series of steps for the program to solve the problem.
A procedural language breaks the program into functions, data structures, etc.
C is a procedural language. In C, variables and function prototypes must be declared before being used.
4) C as a structured programming language
A structured programming language is a subset of the procedural language. Structure means to break a program into parts or blocks so that it may be easy to understand.
In the C language, we break the program into parts using functions. It makes the program easier to understand and modify.
5) C as a mid-level programming language
C is considered as a middle-level language because it supports the feature of both low-level and high-level languages. C language program is converted into assembly code, it supports pointer arithmetic (low-level), but it is machine independent (a feature of high-level).
A Low-level language is specific to one machine, i.e., machine dependent. It is machine dependent, fast to run. But it is not easy to understand.
A High-Level language is not specific to one machine, i.e., machine independent. It is easy to understand.
C Program
In this tutorial, all C programs are given with C compiler so that you can quickly change the C program code.
File: main.c
include
int main() {
printf(“Hello World!\n”);
return 0;
}
Output:
Hello World!
A detailed description of above program is given in next chapters.
C Programming Index
C Tutorial
What is C Language
History of C
Features of C
How to install C
First C Program
Flow of C Program
printf scanf
Variables in C
Data Types in c
Keywords in c
C Operators
C Comments
C Escape Sequence
Constants in C
C Fundamental Test
C Control Statements
C if-else
C switch
C Loops
C do-while loop
C while loop
C for loop
C break
C continue
C goto
Type Casting
C Control Statement Test
C Functions
What is function
Call: Value & Reference
Recursion in c
Storage Classes
C Functions Test
C Array
1-D Array
2-D Array
Array to Function
C Array Test
C Pointers
C Pointers
C Pointer to Pointer
C Pointer Arithmetic
C Pointers Test
C Dynamic Memory
Dynamic memory
C Strings
String in C
C gets() & puts()
C String Functions
C strlen()
C strcpy()
C strcat()
C strcmp()
C strrev()
C strlwr()
C strupr()
C strstr()
C String Test
C Math
C Math Functions
C Structure Union
C Structure
C Array of Structures
C Nested Structure
C Union
C Structure Test
C File Handling
C File Handling
C fprintf() fscanf()
C fputc() fgetc()
C fputs() fgets()
C fseek()
C rewind()
C ftell()
C Preprocessor
C Preprocessor
C Macros
C #include
C #define
C #undef
C #ifdef
C #ifndef
C #if
C #else
C #error
C #pragma
C Preprocessor Test
C Command Line
Command Line Arguments
C Programming Test
C Programming Test
C Programs
Top 10+ C Programs
Fibonacci Series
Prime Number
Palindrome Number
Factorial
Armstrong Number
Sum of digits
Reverse Number
Swap Number
Print “Hello” without ;
Assembly code in C
C program without main
Matrix Multiplication
Decimal to Binary
Number in Characters
Alphabet Triangle
Number Triangle
Fibonacci Triangle
C Strings
The string can be defined as the one-dimensional array of characters terminated by a null (‘\0’). The character array or the string is used to manipulate text such as word or sentences. Each character in the array occupies one byte of memory, and the last character must always be 0. The termination character (‘\0’) is important in a string since it is the only way to identify where the string ends. When we define a string as char s[10], the character s[10] is implicitly initialized with the null in the memory.
There are two ways to declare a string in c language.
By char array
By string literal
Let’s see the example of declaring string by char array in C language.
char ch[10]={‘j’, ‘a’, ‘v’, ‘a’, ‘t’, ‘p’, ‘o’, ‘i’, ‘n’, ‘t’, ‘\0’};
As we know, array index starts from 0, so it will be represented as in the figure given below.
Pause
Next
Mute
Current Time
0:16
/
Duration
18:10
Fullscreen
C Strings
While declaring string, size is not mandatory. So we can write the above code as given below:
char ch[]={‘j’, ‘a’, ‘v’, ‘a’, ‘t’, ‘p’, ‘o’, ‘i’, ‘n’, ‘t’, ‘\0’};
We can also define the string by the string literal in C language. For example:
char ch[]=”javatpoint”;
In such case, ‘\0’ will be appended at the end of the string by the compiler.
Difference between char array and string literal
There are two main differences between char array and literal.
We need to add the null character ‘\0’ at the end of the array by ourself whereas, it is appended internally by the compiler in the case of the character array.
The string literal cannot be reassigned to another set of characters whereas, we can reassign the characters of the array.
String Example in C
Let’s see a simple example where a string is declared and being printed. The ‘%s’ is used as a format specifier for the string in c language.
include
include
int main(){
char ch[11]={‘j’, ‘a’, ‘v’, ‘a’, ‘t’, ‘p’, ‘o’, ‘i’, ‘n’, ‘t’, ‘\0’};
char ch2[11]=”javatpoint”;
printf(“Char Array Value is: %s\n”, ch);
printf(“String Literal Value is: %s\n”, ch2);
return 0;
}
Output
Math Functions in C:
Trigonometry, exponentiation, logarithms, rounding, and other mathematical operations are available in the Cs math library. These approaches are more suited for complex calculations than simple arithmetic programming. The header file <math.h> offers methods for performing mathematical operations such as sqrt(), pow(), ceil(), floor(), etc.
C Math Functions
There are various math methods.h header file. The commonly used functions of math.h header files are given below.
Here are some examples of common math function categories in C:
No. | Function | Description |
---|---|---|
1) | ceil(number) | rounds up the given number. It returns the integer value which is greater than or equal to given number. |
2) | floor(number) | rounds down the given number. It returns the integer value which is less than or equal to given number. |
3) | sqrt(number) | returns the square root of given number. |
4) | pow(base, exponent) | returns the power of given number. |
5) | abs(number) | returns the absolute value of given number. |
C Structure
Why use structure?
In C, there are cases where we need to store multiple attributes of an entity. It is not necessary that an entity has all the information of one type only. It can have different attributes of different data types. For example, an entity Student may have its name (string), roll number (int), marks (float). To store such type of information regarding an entity student, we have the following approaches:
- Construct individual arrays for storing names, roll numbers, and marks.
- Use a special data structure to store the collection of different data types.
Let’s look at the first approach in detail.
- #include<stdio.h>
- void main ()
- {
- char names[2][10],dummy; // 2-dimensioanal character array names is used to store the names of the students
- int roll_numbers[2],i;
- float marks[2];
- for (i=0;i<3;i++)
- {
- printf(“Enter the name, roll number, and marks of the student %d”,i+1);
- scanf(“%s %d %f”,&names[i],&roll_numbers[i],&marks[i]);
- scanf(“%c”,&dummy); // enter will be stored into dummy character at each iteration
- }
- printf(“Printing the Student details …\n”);
- for (i=0;i<3;i++)
- {
- printf(“%s %d %f\n”,names[i],roll_numbers[i],marks[i]);
- }
- }
Output
Enter the name, roll number, and marks of the student 1Arun 90 91 Enter the name, roll number, and marks of the student 2Varun 91 56 Enter the name, roll number, and marks of the student 3Sham 89 69 Printing the Student details... Arun 90 91.000000 Varun 91 56.000000 Sham 89 69.000000
C Preprocessor Directives
The C preprocessor is a micro processor that is used by compiler to transform your code before compilation. It is called micro preprocessor because it allows us to add macros.
Note: Proprocessor direcives are executed before compilation.

All preprocessor directives starts with hash # symbol.
Let’s see a list of preprocessor directives.
- #include
- #define
- #undef
- #ifdef
- #ifndef
- #if
- #else
- #elif
- #endif
- #error
- #pragma
Leave a Reply