Quantcast
Channel: C Programming Archives - QnA Plus
Browsing all 93 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

Count Set Bits of a Number in C

A number consists of multiple bits in its binary representation. For example, an integer would have 32 bits and a long would have 64 bits on 64-bit system. Bit values could either be 0 (not set) or 1...

View Article


Image may be NSFW.
Clik here to view.

Add New Node to XML File Using libxml2 in C

In the previous article, we saw how to parse an XML file. Here we’ll see how to add new node to XML file using C programming language. Here also we’ll use libxml2 parser. We’ll use this XML file as an...

View Article


Image may be NSFW.
Clik here to view.

Delete an XML Node using libxml2 in C

In the previous article we saw how to add a new XML node. Here we’ll see how to delete an an XML node from a file. We’ll use the same example XML file. <?xml version="1.0"?> <catalog>...

View Article

Image may be NSFW.
Clik here to view.

Search for an XML Node using libxml2 in C

XML is widely used format to store or transmit data over internet. Here we’ll see how to search for an XML node in a file. We’ll use this XML file as an example. <?xml version="1.0"?>...

View Article

Image may be NSFW.
Clik here to view.

Circular Linked List in C

Circular linked list is like a regular linked list except its last node points to the first node. Generally the last node of linked list points to NULL. But the last node of circular linked list...

View Article


Image may be NSFW.
Clik here to view.

Execute User Defined Function Before Main() in C

We know that the main() function is the entry point of a program. This is generally true. But we can execute some functions even before main() starts. In some circumstances, you might need to execute...

View Article

Image may be NSFW.
Clik here to view.

Execute User Defined Function before Main() in C++

In the previous article, we saw how to execute user defined function before main() in C. In C++ also we can use same mechanism to execute function before main. Here we’ll explore other options in C++....

View Article

Image may be NSFW.
Clik here to view.

Delete N-th Node from End of a Linked List

In the previous article, we saw how to delete the N-th node of a linked list from the beginning of the list. Here we’ll see how to delete N-th node from the end. N starts with 0. Deleting 0-th node...

View Article


Image may be NSFW.
Clik here to view.

C Program to Check Whether Two String are Equal

Here we’ll see how to check whether two strings are equal. C string (string.h) library already provides a function to do that. Using strcmp() Take two strings as input (say, s1 and s2).Call strcmp()...

View Article


Image may be NSFW.
Clik here to view.

C Program to Check Whether Two Strings are Equal in Case Insensitive Way

In the previous article, we saw how to check whether two strings are equal. But there the comparision was case sensitive. That means, ‘QnAPlus’ and ‘qnaplus’ are not equal. Here we’ll see how we can...

View Article

Image may be NSFW.
Clik here to view.

C Program to Reverse an Array

Here we’ll see how we can write a C program to reverse an array. If an array is ’43 23 45 11 8 54 89′, then after reversal it will become ’89 54 8 11 45 23 43′. We’ll start will a simple approach –...

View Article

Image may be NSFW.
Clik here to view.

C Program to Insert an Element in an Array

Here we’ll see how to insert an element in an array at a particular position, after or before an existing element. If we insert an element in an array, all the elements, after the inserted position,...

View Article

Image may be NSFW.
Clik here to view.

C Program to Delete Element from an Array

Here we’ll see how to delete an element of a particular position from an array. Deleting element means left-shifting the right elements starting from the position. #include <stdio.h> void...

View Article


Image may be NSFW.
Clik here to view.

C Program to Remove All Occurrences of a Number from an Array

In the previous article we saw how to remove an element of a particular position from an array. Here we’ll see how we can remove all occurrences of a number. For example, if an array has the number...

View Article

Image may be NSFW.
Clik here to view.

C Program to Remove all Occurences of a Character from a String

Here we’ll see how to remove all occurences of a character from a string. For example, if we remove the character ‘o‘ from the string “The quick brown fox jumps over the lazy dog“, the result will be...

View Article


Image may be NSFW.
Clik here to view.

C Program to Replace All Occurrences of a Character by Another One in a String

Here we’ll see how to replace all occurrences of a character by another one in a string. Read also: C program to remove all occurrences of a character. #include <stdio.h> void replace_char(char*...

View Article

C Program to List All Files in a Directory

Listing all files in a directory is a very common programming requirement. Here we’ll see how to read and display all file names in a directory using C directory entry (dirent) library. #include...

View Article


C Program to List All Files Including Subdirectories

In the previous article, we saw how to list all files in a particular directory. That program does not display the files of the subdirecties. Here we’ll see how to display the files of the current...

View Article

C Program to Count Occurrences of Each Element in an Array

Here we’ll see how to write C program to count occurrences of each element in an array. The C program will check how many times a particular integer occurs in the array. #include <stdio.h>...

View Article

C Program to Find the Longest Word in a String

A word is a consecutive non-whitespace character set. The C program here will find out the longest word in a given string. If multiple words are present with the same length of the longest one, it...

View Article
Browsing all 93 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>