Found 1401 Articles for C

Explain insertion of elements in linked list using C language

Bhanu Priya
Updated on 20-Jun-2024 22:12:24

3K+ Views

Linked lists use dynamic memory allocation i.e. they grow and shrink accordingly. They are defined as a collection of nodes. Here, nodes have two parts, which are data and link. The representation of data, link and linked lists is given below −Operations on linked listsThere are three types of operations on linked lists in C language, which are as follows −InsertionDeletionTraversingInsertionConsider an example, wherein we insert node 5 in between node 2 and node 3.Now, insert node 5 at the beginning.Insert node 5 at the end.Insert node 5 at the end.Note:We cannot insert node 5 before node 2 as the ... Read More

Explain the evaluation of expressions of stacks in C language

Bhanu Priya
Updated on 20-Jun-2024 22:17:25

18K+ Views

Stack is a linear data structure, where data is inserted and removed only at one end.AlgorithmsGiven below is an algorithm for Push ( ) −Check for stack overflow.if (top = = n-1) printf("stack over flow");Otherwise, insert an element into the stack.top ++ a[top] = itemGiven below is an algorithm for Pop ( ) −Check for stack underflow.if ( top = = -1) printf( "stack under flow");Otherwise, delete an element from the stack.item = a[top] top --Given below is an algorithm for Display ( ) −if (top == -1) printf ("stack is empty");Otherwise, follow the below mentioned algorithm.for (i=0; i='0' && ch

Explain the conversions of expressions of stacks in C language

Bhanu Priya
Updated on 21-Jun-2024 21:50:10

1K+ Views

Stack is a linear data structure, where data is inserted and removed only at one end.AlgorithmsGiven below is an algorithm for Push ( ) −Check for stack overflow.if (top = = n-1) printf("stack over flow");Otherwise, insert an element into the stack.top ++ a[top] = itemGiven below is an algorithm for Pop ( ) −Check for stack underflow.if (top = = -1) printf("stack under flow");Otherwise, delete an element from the stack.item = a[top] top --Given below is an algorithm for Display ( ) −if (top == -1) printf ("stack is empty");Otherwise, follow the below mentioned algorithm.for (i=0; i

Explain linear data structure queue in C language

Bhanu Priya
Updated on 24-Mar-2021 13:59:45

496 Views

Data structure is collection of data organized in a structured way. It is divided into two types as explained below −Linear data structure − Data is organized in a linear fashion. For example, arrays, structures, stacks, queues, linked lists.Nonlinear data structure − Data is organized in a hierarchical way. For example, Trees, graphs, sets, tables.QueueIt is a linear data structure, where the insertion is done at rear end and the deletion is done at the front end.The order of queue is FIFO – First In First OutOperationsInsert – Inserting an element into a queue.Delete – Deleting an element from the ... Read More

Explain C Error handling functions

Bhanu Priya
Updated on 24-Mar-2021 13:53:46

676 Views

File is collection of records or is a place on hard disk, where data is stored permanently.Operations on filesThe operations on files in C programming language are as follows −Naming the fileOpening the fileReading from the fileWriting into the fileClosing the fileSyntaxThe syntax for opening a file is as follows −FILE *File pointer;For example, FILE * fptr;The syntax for naming a file is as follows −File pointer = fopen ("File name", "mode");For example, fptr = fopen ("sample.txt", "r"); FILE *fp; fp = fopen ("sample.txt", "w");Error Handling in FilesSome of the errors in files are as follows −Trying to read beyond ... Read More

Explain fgetc() and fputc() functions in C language

Bhanu Priya
Updated on 21-Jun-2024 22:00:27

3K+ Views

File is collection of records or is a place on hard disk, where data is stored permanently.Operations on filesThe operations on files in C programming language are as follows −Naming the fileOpening the fileReading from the fileWriting into the fileClosing the fileSyntaxThe syntax for opening a file is as follows −FILE *File pointer;For example, FILE * fptr;The syntax for naming a file is as follows −File pointer = fopen ("File name", "mode");For example, fptr = fopen ("sample.txt", "r"); FILE *fp; fp = fopen ("sample.txt", "w");fgets( ) and fputs( ) functions fgets() is used for reading a string from a file.The ... Read More

Explain the functions putw() and getw() in C language

Bhanu Priya
Updated on 21-Jun-2024 23:45:30

10K+ Views

File is collection of records or is a place on hard disk, where data is stored permanently. Operations on files The operations on files in C programming language are as follows − Naming the file Opening the file Reading from the file Writing into the file Closing the file Syntax The syntax for opening a file is as follows − FILE *File pointer; For example, FILE * fptr; The syntax for naming a file is as follows − File pointer = fopen ("File name", "mode"); For example, fptr ... Read More

Explain putc() and getc() functions of files in C language

Bhanu Priya
Updated on 22-Jun-2024 17:42:24

10K+ Views

A file represents a sequence of bytes, regardless of it being a text file or a binary file. File is collection of records or is a place on hard disk, where data is stored permanently. Operations on files The operations on files in C programming language are as follows − Naming the file Opening the file Reading from the file Writing into the file Closing the file Syntax The syntax for opening a file is as follows − FILE *File pointer; For example, FILE * fptr; The ... Read More

Explain append mode operation of files in C language

Bhanu Priya
Updated on 24-Mar-2021 13:26:21

551 Views

File is collection of records or is a place on hard disk, where data is stored permanently.Need of filesEntire data is lost when a program terminates.Storing in a file preserves the data even if, the program terminates.If you want to enter a large amount of data, normally it takes a lot of time to enter them all.We can easily access the content of files by using few commands.You can easily move your data from one computer to another without changes.By using C commands, we can access the files in different ways.Operations on filesThe operations on files in C programming language ... Read More

Explain read mode operation of files in C language

Bhanu Priya
Updated on 24-Mar-2021 13:25:59

773 Views

File is collection of records or is a place on hard disk, where data is stored permanently.Need of filesEntire data is lost when a program terminates.Storing in a file preserves the data even if, the program terminates.If you want to enter a large amount of data, normally it takes a lot of time to enter them all.We can easily access the content of files by using few commands.You can easily move your data from one computer to another without changes.By using C commands, we can access the files in different ways.Operations on filesThe operations on files in C programming language ... Read More

Advertisements