C Programming Tutorial | Learn basic C Computer Programming language with examples

Here in this c programming tutorial we are explaining about the c language which had so many powerful features still used by many programmers. Every programmer should know the basics of cprogramming. C programming language is one of the oldest and most powerful programming language available. It is the mother of all other languages used for programming. C is the basic programming language which was developed in 1972 and it is a procedure oriented language, also called mid level programming language. C-programming-language has a lot of features which is used by many computer programming languages. A C program consists of several functions used for various purposes, it uses several default c libraries and also various headerfiles. Every c program consists of a main() function and also stdio headerfile to load basic input output libraries. In this cprogramming tutorial we explain Clanguage.

History Of CLanguage - Computer programming

C language was created by Dennis Ritche at bell research center. Dennis Ritche is known as father of clanguage. It was proposed to utilize the UNIX Operating framework. It acquires numerous gimmicks of past languages, for example, B and BPCL."C programming language" have numerous peculiarities which are given underneath.
it is portable
Mid-level programming language
organized programming language
have exceptionally Rich Library
incorporates Memory Management
additional Fast Speed
Pointers for utilizing memory area as a part of variables
capacity Recursion
very Extensible

Tokens in C Language

C program have numerous tokens, anything utilizing in as a part of c program is called as token which is either a keyword, an identifier, a constant, a string, or an symbol.

Basic Library functions in c language - Computer programming language

C programming language has a lot of library functions that is the functions already written and we can use and access it by using the library functions. for example printf and scan f are such already written library functions in stdio.h - library functions for input and output commands .
#include conio.h;includes the console input output library functions. The getch() function is defined in conio.h file.

Input output functions of C Programming language.

the syntax that is used for printing any output to the console is called printf, it is a function already written in the stdio library of a c program
printf(“format string”,arguments_list);
Format string can be integerwhich is represented by %d, %c for character, %s string etc.
scanf() every c program needs to read the input from the user console, for that we are using a c library function scan f which gets the input from the console by scanning the console to the program.
scanf(“format string”,argument_list);

Data types of C program

There are four types of data types in C language. Types Data Types
Basic Data Type int, char, float, double
Derived Data Type array, pointer, structure, union
Enumeration Data Type enum
Void Data Type void

Basic Keywords in CProgramming Language

A keyword is a reserved word You cannot use it as a variable name, constant name etc. There are 32 keywords in C language as given below:
auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while

Operators In C Programming language

There are following types of operators to perform different types of operations in C language. C has a lot of operators which is usefull while programming. in this c tutorial we are using almost all operators in the c programs
Arithmetic Operators
Relational Operators
Shift Operators
Logical Operators
Bitwise Operators
Ternary or Conditional Operators
Assignment Operator
Misc Operator

Control structures in C programming langugage - C Basics

Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false
There may be a situation, when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a cfunction is executed first, followed by the second, and so on. CProgramming language provide various control structures that allow for more complicated execution paths. A loop statement allows us to execute a statement or group of statements multiple times and following is the general form of a loop statement in most of the programming languages
Some of control structures used in c programs are:
do-while loop
while loop
for loop

There are many ways to use if statement in C language:
If statement
If-else statement
If else-if ladder
Nested if

In if statement is used to execute the code if condition is true.
syntax:- if(expression){ //code to be execute

The if-else statement is used to execute the code if condition is true or false.
Syntax: if (expression){ //code to be executed if condition is true }
else{ //code to be executed if condition is false }

The if else-if statement is used to execute the code if condition is true or false.
Syntax: if (condition1){ //code to be executed if condition1 is true }
else if (condition2){ //code to be executed if condition2 is true }
else if (condition3){ //code to be executed if condition3 is true } ...
else{ //code to be executed if all the conditions are false }

Syntax: switch (expression){
case value1: //code to be executed;
; //optional
case value2: //code to be executed;
; //optional ......
: code to be executed
all cases are not matched; }

Types of loops in C language:-

Loops are used to execute a block of code or a part of program of the program several times.
There are 3 types of loops in c language.
do while
it is better if you have to execute the code at least once.
Syntax:-do { //code to be executed }
while (condition);

It is better if number of iteration is not known by the user.
Syntax:-while (condition){ //code to be executed }

It is good if number of iteration is known by the user.
Syntax:-for (initialization;condition;incr/decr){ //code to be executed }

it is used to break the execution of loop (while, do while and for) and switch case.
Syntax:- jump-statement;

it is used to continue the execution of loop (while, do while and for). It is used with
if condition within the loop.
Syntax:- jump-statement;

Functions in C Language - most powerful computer programming language

A cfunction is a group of statements that together perform a task. Every C program has at least one cfunction, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate cfunctions. How you divide up your code among different functions is up to you, but logically the division usually is so each function performs a specific task. A cfunction declaration tells the compiler about a cfunction its name, return type, and parameters. A cfunction definition provides the actual body of the function.
The C standard library provides numerous built-in functions that your program can call. For example, function strcat() to concatenate two strings, function memcpy() to copy one memory location to another location and many more functions. To perform any task, we can create function. A function can be called many times. It provides
and code
.Advantage of Cfunction:-
Code Resuability
Code optimization
return_type function_name(data_type parameter...){ //code to be executed }
Syntax to call function:- variable=function_name(arguments...);
In call by value, value being passed to the function is locally stored by the function parameter in stack memory location. If you change the value of function parameter, it is changed for the current function only. It will not change the value of variable inside the caller method such as main().
In call by reference, original value is modified because we pass reference (address).

Recursion In C basic programming

A function that calls itself, and doesnt perform any task after Cfunction call, is know as tail recursion In tail recursion, we generally call the same function with return statement.
Syntax:- recursionfunction(){ recursionfunction();//calling self function }

Arrays In C language

Array in C language is a collection or group of elements (data). All the elements of array are homogeneous (similar). It has contiguous memory location.
Declaration of array:-
data_type array_name[array_size]; Eg:- int marks[7];
Types of array:-
1-D Array
2-D Array
Code Optimization
Easy to traverse data
Easy to sort data
Random Access 2-d Array is represented in the form of rows and columns, also known as matrix. It is also known as array of arrays or list of arrays
Declaration of 2-d array:- data_type array_name[size1][size2];

Pointers in C programming language

Pointer is a user defined data_type which create the special types of variables. It can hold the address of primitive data type like int, char, float, double or user define datatypes like function, pointer etc. it is used to retrieving strings, trees etc. and used with arrays, structures and functions. Pointer reduces the code and improves the performance. We can return multiple values from function using pointer. It make you able to access any memory location in the computer’s memory.
Syntax:- int *ptr;
int (*ptr)();
int (*ptr)[2]; For e.g.-
inta=5; // a= variable name//
int* ptr; // value of variable= 5// ptr=&a; // Address where it has stored in memory : 1025 (assume) //

C Strings - Computer programming language

Note that along with C-style strings, which are arrays, there are also string literals, such as "this". In reality, both of these string types are merely just collections of characters sitting next to each other in memory. The only difference is that you cannot modify string literals, whereas you can modify arrays. Functions that take a C-style string will be just as happy to accept string literals unless they modify the string (in which case your program will crash). Some things that might look like strings are not strings; in particular, a character enclosed in single quotes, like this, 'a', is not a string. Its a single character, which can be assigned to a specific location in a string, but which cannot be treated as a string. Remember how arrays act like pointers when passed into functions? Characters dont, so if you pass a single character