Posts

Showing posts from July, 2015

Binary Search: Search an element in sorted array

C program for binary search: Binary search works only in sorted array. Prerequisite of binary search is that array should be sorted. If you want to implement binary search in unsorted array then you should sort array using any sorting algorithm like merge sort, quick sort etc and then implement binary search.

C program for bubble sort

Bubble sort in c: Bubble sort is the simplest algorithm for sorting elements of array. We can sort elements in ascending and descending order using bubble sort algorithm.

Find common characters in two string

Simple C program to find and print common characters in two strings. This program will find common character and will print them. This program will print common characters with frequency of character that are present in both strings.

Highest frequency character in string c program

This program will find the character with highest occurrence in string. If there are two or more character with highest and same frequency in string then program will print alphabetically first character in string. For example if string is "programmingside". Here 'g', 'r', 'm', 'i' occurring  two times so program will print 'g'.

Remove duplicate elements from unsorted array

Simple C program to remove duplicates from array.

Remove duplicates from a sorted array

Given a sorted array and remove duplicates from array. Simple C program to remove duplicates from array.

What is the prerequisite for binary searching

Prerequisite for binary searching is the array should be sorted Otherwise binary searching will not work fine. If we apply binary searching in unsorted array then it can give correct answer by mistake.

Find pair of elements in array that sum is given number k

Simple C program to find pair in array. Simple method is run two for loop and find pair.

Count frequency of character in string C program

Simple C program to count frequency of each character in a string. If string a "programmingside" then frequency of characters:

Count Common characters in two strings

Given two strings, count total number of common characters. For example if two strings are "coder" and "side" then common characters are 2 ( 'd' and 'e' ). If strings are "Programming" and "Side" then common character is 'i'. If strings are "aabbcc" and "aabcc" then common characters are 5 ( 2'a', 1'b', 2'c' ).

Count total number of nodes in linked list using recursion

Simple C Program to count total number of node in a linked list using recursion. Count total number of nodes using iterative method.

Count total number of elements in linked list

Simple C Program to count total number of elements in a linked list.

Programming Interview Questions Collection

In this post, we are giving interview questions that are asked in interview. These questions might help you in the interview. Here these programs are asked in interview to our friends and colleagues. There are also so many questions that are asked in interview.

Convert number from octal to binary C program

Convert number from octal to binary. Octal number is a base 8 number and octal number contains 0,1,2,3,4,5,6,7 digits and binary number is a base 2 number and it contains 0 and 1.

Rotate matrix by 90 degrees In place C Program

Simple C program to rotate matrix by 90 degrees.

Print matrix by 90 degrees rotation C program

Given a matrix. Rotate it by 90 degrees.

Sort array in the wave form C Program

A array is given and sort it in the wave form. Wave form of a array: If array is {1,4,2,7,8,4,9,3} then sort it like {4,1,7,2,8,4,9,3}. Like arr[0]>=arr[1]<=arr[2]>=arr[3]<=arr[4]....

Print a matrix in the wave form C program

Image
You are given a matrix arr[m][n] then print it in the wave form as given in the image.

Decimal to octal conversion C program

Simple C program for decimal to octal conversion

Decimal to hexadecimal conversion C Program

Decimal number is a base 10 number and hexadecimal number is base 16 number. In decimal number number there are 0 to 9 digits and in hexadecimal number 0 to 9 digits plus A, B, C, D, E ,F characters. Number 1324 is a decimal number and number 1A2 is hexadecimal number.

Sum of diagonal elements of matrix C++ Program

Simple C++ program to calculate sum of diagonal elements of a matrix.

C++ Program for transpose of matrix

Transpose of a matrix is a matrix whose columns are rows of original matrix and rows are columns of original matrix.

C++ Program to multiply two matrices

In mathematics, to multiply two matrix what we do. First we check the number of column in first matrix is equal to number of rows in second matrix. If they are not equal then we can't multiply them.

Subtraction of two matrices C++ Program

Simple C++ program to subtract one matrix from another matrix and store data into third matrix and then print third matrix.

C++ Program to add two matrices

Simple C++ Program to add two matrix into third matrix. To add two matrix , we add corresponding position elements of both matrix.

Print matrix or two dimension array in C++

Image
Simple C++ program to print matrix. To print matrix, we use two for loop. First for loop is for rows in matrix and second for loop is for columns in matrix.

Calculate sum of array elements C++ Program

Simple C++ program to calculate sum of array elements. To calculate sum of array elements, first we declare a variable sum and initialize it to 0 and then add array elements one by one into sum.

Direct count total digits in a number C++ Program

Here is a simple C++ program to count total number of digits in a number. To count digits, we use log. And for this purpose we use cmath library.