C Program to Delete the First Node of a Linked List

Here we’ll see how write C program to delete the first node of a linked list. Head always points to the first node. Head will move to where the first node is currently pointing to. First node can either point to the second node or to NULL in case the first node is the only … Continue reading “C Program to Delete the First Node of a Linked List”

C Program to Swap Two Numbers

Here we’ll discuss about different techniques how we can swap two numbers. Swapping two numbers means exchanging the values of two variables. For example, if value of A is 5 and value of B is 10, then after swapping values of A and B would be 10 and 5 respectively. Swap Two Numbers Using Third … Continue reading “C Program to Swap Two Numbers”

C Program to Reverse a Linked List

Reversing a linked list means re-arranging the next (connection) pointers. Head will point to the last node and the first node will point to NULL. Direction of other next pointers will change. If a linked list looks like this: After reversal, it will look like: Logic to Reverse a Linked List Take the first node … Continue reading “C Program to Reverse a Linked List”

C Program to Count Characters, Words and Lines in a File

To get a quick summary of a file like total number of characters, words and limes, Linux already has a tool, wc. Here we’ll see how to write C program to get the similar information. Strategy to Count Characters, Words, Lines in a File Take input of a file name and open that file in … Continue reading “C Program to Count Characters, Words and Lines in a File”

C Program to Count Words in a String

For our purpose, a word is a set of consecutive characters without any white-space. For example, ‘qnaplus‘ is a word but ‘qna plus‘ has two words. Here we’ll see how to write C program to count the number of words in a string. We can think of a simple solution of counting the white spaces … Continue reading “C Program to Count Words in a String”

0
0
0
5
0
0