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

Image may be NSFW.
Clik here to view.

How to Implement Merge Sort in C?

Merge sort is efficient, general-purpose sorting algorithm. Unlike bubble sort or insertion sort, it is usable in most practical cases. Merge sort is divide and conquer algorithm. Here we’ll see how to...

View Article


Image may be NSFW.
Clik here to view.

How to Implement Quick Sort in C?

Quick Sort is an efficient sorting algorithm developed by Tony Hoare in 1959. It is still a commonly used sorting algorithm in most practical cases. If implemented properly, it is two or three times...

View Article


Image may be NSFW.
Clik here to view.

How to Implement Shell Sort in C Programming?

Shell Sort (aka shellsort) can be thought as an improvement over insertion sort. To understand shell sort, we have to recall how insertion sort works. In insertion sort at any moment, the whole array...

View Article

C Program to Find Second Largest Element in an Array

Here we’ll see the possible solutions of finding the second largest element in an array. By Sorting the Array: Easy solution that I can think of to find the second largest element in an array is to...

View Article

How to find position of a digit in a number in C programming?

This program will find out the position of a digit in a number. For example digit 4 is present in 41234253 at 4th and 8th positions from left.Logic is simple, we start with the number say 41234253 and...

View Article


C Program to Sleep in Milliseconds

We don’t have millisecond level control in the sleep() function. But in Linux we can implement our own function that will take duration in milliseconds as input and sleep for that duration. Using...

View Article

C Program to Reverse an Integer

Here we’ll see how to write C program to reverse an integer. The reverse_integer() function takes an integer like 5234569 and returns 9654325. #include <stdio.h> unsigned int...

View Article

C Program to Reverse a String

Here we’ll see how to write a C program to reverse a string. Solution 1 void reverse_string(char *input, char *output) { int len = 0, i = 0; if(input == NULL || output == NULL) return; len =...

View Article


C Program to Check Whether a String is Palindrome

Palindrome string is a string that reads the same in both directions, forward and backward. For example, “madam” reads the same from both directions. If you reverse a palindrome string, the reversed...

View Article


C Program to Check Whether a Number is Palindrome

Palindrome number reads the same from both directions, forward and backward. For example, “156434651” reads the same from both directions. If we reverse a palindrome number, the reversed number would...

View Article

C Program to Print Fibonacci Series

Fibonacci series is a series of numbers where each number is the summation of two previous numbers. The first two numbers of Fibonacci series are 0 and 1. Here is an example of Fibonacci series: 0 1 1...

View Article

Image may be NSFW.
Clik here to view.

C Program to Find Minimum and Maximum Numbers in an Array

Here we’ll see how to write C program to find the minimum and maximum numbers in an array. #include <stdio.h> int main() { int arr[128]; int n = 0, i = 0, min = 0, max = 0; printf("Enter the...

View Article

Image may be NSFW.
Clik here to view.

C Program to Calculate Factorial of a Number

Factorial of a number N, (N!) is 1*2*3*4*5*…..*N. Here we’ll see how to write C program to calculate the factorial value of a number. Here are the C functions that calculate the factorial value of a...

View Article


C Program to Print Current Date and Time

Quite often we need to print the current date and time from our program. For example, when we write log messages, we generally attach the timestamp with every message. Here we’ll see how to write a C...

View Article

C Program to Calculate the Sum of All Elements in an Array

Here is the C program that prints the sum of all elements in an array. #include <stdio.h> int main(){ int arr[] = {23, 45, 1, 34, 56, 76, 74}; int i = 0, sum = 0; int len =...

View Article


Image may be NSFW.
Clik here to view.

Command Line Arguments in C Programming

An application takes inputs in various ways. It can ask for input from user while it is running. It can read something from file or socket. Another way is, we can give inputs in time of starting the...

View Article

Image may be NSFW.
Clik here to view.

C Program to Check Whether Two Linked Lists are Equal

Here we’ll see how to write a C program to compare two linked lists. First we’ll create three linked lists, first two are equal and third one is different. We’ll compare these linked lists using the...

View Article


C Program to Print the Length of a Linked List

Here we’ll see how to write a C program to print the length of a linked list. The function get_length() takes a linked list as input and returns the length of it. First we’ll create a linked list and...

View Article

Image may be NSFW.
Clik here to view.

C Program to Search for an Element in Linked List

Here we’ll see how to write a C program to find an element in a linked list. The function is_present() takes a linked list (head pointer) and a value (val). If the value is present in any of the...

View Article

C Program to Find the Sum of all Digits of a Number

Here we’ll see how to write a C program to find the summation of all digits in a number. #include <stdio.h> int sum_digits(int n) { int sum = 0; while(n) { sum += (n % 10); n /= 10; } return...

View Article
Browsing all 93 articles
Browse latest View live


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