You're online now.

Hurray! you are online now.


    int main(){
    return 0;

This is the syntax(Boilerplate code)

printf(): printf() function for used to show the output.


scanf(): scanf() function for used to take the input from users.

scanf("format_specifier", &variable);


A comment is not executed by the compiler. The comments is used for the increase the readability. In c programming language two types of comments.

Single Line comment

// This is single Line Comment

Multi Line comment

/* This is
    Multiple line


Datatype is the type of data to declare the variable.

Integer Type

int variable_name;

Character Type

char var;

Float Type

float var_name;

Double Type

double variable_name;

void Type


Escape Sequence

It is a sequence of characters starting with a backslash, and it doesn't represent itself when used inside string literal.

// Beep / Alarm: It produce the beep sound.
// backspace: Add Backspace
// new line: Add new line
// carriage return
// Tab: Gives the tab space
// Backslash: Add backslash
// Single Quote: Add single quotation mark.
// Question Mark: Add Question mark
// Octal Number: It represents the value of an octal number.
// Hexadecimal Number: It represents the value of an Hexadecimal number.
// Null: The null character is usually used to terminate a string.

Conditional statement

Conditional statement is used to perform the logical operation in program.

// if statement
    if(/* condition */){
    /* statement; */
// if-else statement
    if(/* condition */){
    /* statement*/
    /* statement */
// if-else-if-else statement
    /* statement */
    else if(/* condition */){
    /* statement */
    /* statement */
// switch statement
    case 1 :
    case 2 :
    /* statement */
    default :
    /* default statement */

Loops in c

loop is used for, the line of code execute repeatedly then programmer used loops.

// for loop in c
    for(/*initialization*/ ; /*condition*/; /*increament/decrement*/)
    /* code*/
// while loop
// do while loop
    /* code */
// break statement: break keyword inside the loop is used to terminate the loop.
/* continue statement: continue keyword skips the rest of the current
    iteration of the loop and returns to the starting point of the loop. */

Function and Recursion

Function are used to divide the program in pieces and used function many times in our program.

// function definition
    return_type name_function(data_type parameter ...){
    // code of the function


Recursion is when a function calls itself to solve the problem. Which function is calls iteself called the recursive function.

void fun(){
    ... ... ..
    ... ... ..


Pointer is the variable which contains the address of the another variable.

data_type = *variable_name;


Array is the collection of the same datatypes.

data_type array_name[array_size];

Access array element



A string is a 1-D character Array terminated by a null character("\0").

// declaration
    char string_name[string_size];

gets() function: It allows to enter the multi-word string.


puts() function: It used to show the string.


strlen() function: It is used for to calculate the length of string.


strcpy() function: it is used for copy the string to another one.

strcpy(destination, source);

strcat() function: It is used for concatenate two string.

strcat(first_string, second_string);

strcmp() function: It is used for compare two string.

strcmp(first_string, second_string);

Structure in c

The structure is a collection of different types of variable in a single. Define structure means creating a new data type.

// Syntax
    struct structure_name
    datatype member1;
    datatype member2;
    ... .... ...

typedef keyword: typedef function allows user to provide alternative names for the primitive and user-defined data type.

typedef struct structure_name
    datatype member1;
    datatype member2;
    ...   ...  ...


struct structure_name
    datatype member1;
    datatype member2;
    ...   ...  ...
    typedef structure_name new_name;

File Handling in c

File handling in c enables us to create, update, read and delete the files stored on the local file system through our C program.

// File Pointer
    FILE *filepointer;
// Opening a file: It is used to open file in C
    filePointer = fopen(filename.txt,w);
// fscanf() function: It is used to read the content of file.
    fscanf(FILE *stream, const char *format, ...);
// fprintf() function : It is used to write content into the file.
    fprintf(FILE *fptr, const char *str, ...);
// fgetc() function : It reads a character from a file opened in read mode.
    fgetc(FILE *pointer);
// fputc() function : It writes a character to file opened in write mode.
    fputc(char, FILE,*pointer);
// Closing a File : It close the file.

Dynamic Memory Allocation in c

The concept of dynamic memory allocation in c language enables the C programmers to allocates memory at runtime.

// malloc() function
    ptr = (TypeCast*)malloc(size());
// calloc() function
    ptr = (TypeCase*)calloc(n,size);
// free function
// realloc() function
    ptr = realloc(ptr, x);
🖤 0
Buy me coffee ☕



No comments here...