# C Programming

## C Programming Language Code Examples

Program code to access every 2-D Array we requires 2 subscript variables. y - Refers the Row number. x - Refers Column number. a[1][0] refers element belonging to first row

C Programming input a character and Check whether given character is alphabet, digit or special character using if else. A character is alphabet if it in between a-z or A-Z. Character

To concate two arrays, we need at least three array variables. We shall take two arrays and then based on some constraint, will copy their content into one single array. We shall

C program code input any number from user and check whether the Least Significant Bit (LSB) of the given number is set (1) or not (0). How to check whether the least significant...

Converting an integer to a string with a fixed width. If the width is too small, the minimum width is assumed. Generate digit characters in reverse order. Shift the string to the right

C Language program code sample input any number and check whether the given number is even or odd using bitwise operator. How to check whether a number is even or odd using

Program Input number and nth bit position to clear from user. Store it in some variable say j and n. Left shift 1, n times i.e. 1 << n. Perform bitwise complement with the above result...

Pipe the output of program to the input of another. Duplicate stdin and stdout so we can restore them later. Make the write end of the pipe stdout. Run the program. Its output will

C program code to 2d example insertion sort [linked list]. Insert a node directly at the right place in the linked list. Insert some numbers into the linked list. Print the list. Free the list

To calculate area and circumference we must know the radius of circle. C program code will prompt user to enter the radius and based on the input it would calculate the values. Make

Program input a number and check whether the number is Perfect number or not. Perfect number is a positive integer which is equal to the sum of its proper positive divisors. So 6 is

If the list is empty, create first node. Go to last node. Add node at the end. Preform a bubble sort on the linked list. The 'c' node precedes the 'a' and 'e' node pointing up...

C Program Code input Decimal number from user and convert to binary number system. Decimal number system is a base 10 number system. Decimal number system uses only 10

'Insertion Sort Algorithm' picks elements one by one & places it to the right position where it belongs in the "Sorted List of Elements". In C program we have "implemented the same"

This C Program adds two complex numbers. A Complex Number is a number that can be put in the form a + bi, where a and b are real numbers & i is called imaginary unit, where...

C Program 'checks the substring' is present in a given string. Program accepts both string & substring. Then checks whether the substring is present in the string. Enter search substring

Program 'takes a number' as input and finds a Greater number of the entered number using same digits. Take a number as input. Reverse the number and store it in the array. Using for

C Program accepts the sorted array and does search using "Binary Search". Binary search is algorithm for locating the position of an item in a 'Sorted Array'. A search of sorted data, in

C program code to 'Check whether a String' is palindrome or not without using loop. How to Check whether a string is 'Palindromic String' or not in C. Palindrome string is special string

Declare recursive function to find factorial of a number. First let us give a meaningful name to our function, say fact(). Factorial Function accepts an integer input whose factorial is to

Recursive function in C language to find GCD (HCF) of two numbers. Find GCD ( Greatest Common Divisor ) or HCF ( Highest Common Factor ) of two numbers using recursion in C

Lets take 2 Strings as input and store them in the arrays string1[] and string2[] respectively. "Count the Number" of characters in both the arrays and store the result in the variables co1

How to find maximum and minimum element in an array using recursion in C programming. Recursion works on the concept of divide and conquer. We break the problem in its smallest

A plane figure with 4 sides & 4 right angles & having Equal Opposite sides. Adjucent sides makes an Angle of 90 degree. Just compute the area of a Rectangle if you know its length

In C programming language we use bitwise AND & operator to check status of any bit. Bitwise AND operation evaluate each bit of resultant value as 1, if corresponding bit of...

Declare function to find all prime numbers in given range. First give a meaningful name to our function. Say printPrimes() function will print all prime numbers in a range. Declare...

Record the time program starts execution. Record the current time, using the alternate method of. Convert the time_t value into a type tm structure. Create and display a string

C program code to input character from user and check whether character is Uppercase or Lowercase alphabet using If Else Statement. Input a character from user. Store it in some

Before accepting the Elements Check if no of rows and columns of both matrices is equal. Accept the Elements in Matrix 1 and Matrix 2. Addition of two matrices. Print out the matrix

The if...else statement executes some code if the test expression is true (nonzero) & some other code if the test expression is false (0). If test expression is true, codes inside the body

Take the integer which you want to check as input and store it in a variable number. Using if, else statements check whether the integer is Greater or Lesser than zero. If it is greater...

C Language program to Amstrong Numbers. Armstrong Number is a number which equal to the sum of the cubes of its individual digits For example, 407 is an armstrong number as

English Alphabets a, e, i, o, u both lowercase & uppercase are known as vowels. Alphabets other than Vowels are known as Consonants. Input an alphabet from user. Store it in some

Input number from user and check whether the number is even or odd using switch case. A number is said even number if it is exactly divisible by 2. In C we use Modulo operator...

C Code Declare recursive function to find nth Fibonacci term. Assign a meaningful name to the function, say fibo(). The function accepts an integer hence update function declaration

Break Statements are useful when you want your program-flow to come out of the switch body. Whenever break is encountered in the switch body, the control comes out of switch

Give a meaningful name to the function, say sumOfNaturalNumbers(). The function must accept two inputs i.e. the lower & upper limit to find sum. Pass two integer parameters to

This 2D-Drawing Program is used for drawing circles, arcs, rectangle, lines and many more. Controls for the two-dimensional drawing. Enter radius of circle, enter radius, starting...

First give a meaningful name to our function. Say max() function is used to find maximum between two numbers. Second, we need to find maximum between two numbers. And

C Program to input a number from user and check whether given number is Armstrong number or not. Armstrong number is n-digit number that is equal to the sum of the nth...

C First give a meaningful name to our prime checking function say isPrime() function will check a number for prime. Since our function checks a number for prime condition. Hence

C Program code input any number from user and find cube of the a number using function. Lets assign meaningful name to the function, say cube(). Function should accept a number

C program input decimal number and convert to Hexadecimal number system. The Decimal number system is a base 10 number system. Decimal number system uses 10 symbols to...

Prime numbers are positive integers greater than 1 that is only divisible by 1 and self. For example: 2, 3, 5, 7, 11 etc... C program input number and check whether the number is...

Takes the binary number (entered by user) as input and converts it into a decimal number using function. To understand this program, you should be familiar with the following C...

C program input number and check number is Palindrome or not using Loop. Palindrome number is such number which when reversed is equal to the original number. 121, 12321,...

For Loop in C. First initialization happens and the counter variable gets initialized. Second step the condition is checked, where counter variable is tested for the given condition, if...

Accept the given decimal number. If number is less than 8 the octal number is the same. If the number > 7 then Divide the number with 8. Write down the remainder. Do steps 3 and

In C program user is asked to enter the binary number and the program then converts that binary number to the octal number by calling a user defined function. To understand this...

C Converts a decimal number into binary and count the number of 1s. The c program uses module operation and multiplication with base 2 operation for conversion. It also uses

C language program take the number of days as input. For the number of years, divide the input by 365 and obtain its quotient. For the number of weeks, divide the input by 365 and

Program example catches the Ctrl-C (SIGINT) signal for the first time and prints a output rather but exits on pressing ctrl-c again. You have presses Ctrl-C, please press again to exit

C language program code to accept a matrix of order M x N and store its elements and interchange the main diagonal elements of the matrix with that of secondary diagonal

C language example implementation of LN command using system calls. Error: Too Few Arguments. Error: Too Many Arguments. Error: Invalid Syntax. Error: File name not...

C program to input any decimal number from user and convert it to binary number system using bitwise operator. How to convert from decimal number system to binary number...

C Program Code Bitwise operators During computation, mathematical operations like: addition, subtraction, addition and division are converted to bit-level which makes and

C Convert an integer to a string. Caller must allocate string array. Function returns string to allow. Use of the function in an expression. Generate digit characters in reverse order...

C program to read elements in two matrices and add elements of both matrices. C code for addition of two matrix. Matrix addition program in C. Logic to add two matrix in C.

In this program, user is asked to entered the number of rows r and columns c. The value of r and c should be less than 88 in this program. The user is asked to enter elements of two...

Code read elements in an array from user and count total number of duplicate elements in array. C program code to find all duplicate elements in an unsorted array. How to list all