## Programs List | Programming ExamplesA list of programs or programming examples on C, C++, Java, C#, Python and PHP are given below. - Basic Programs
- Number Programs
- Array Programs
- Matrix Programs
- Pattern Programs
- String Programs
- Tree Programs
- Singly Linked List Programs
- Circular Linked List Programs
- Doubly Linked List Programs
- Miscellaneous
## Basic Programs1) Program to calculate the area of rectangle
Area of Rectangle = Width * Height = 10 * 5 = 50 2) Program to calculate the volume of sphere
Volume = (4.0/3.0) * pie * (radius * radius * radius); = (4.0/3.0) * 3.14 * 48 * 48 * 48 = 463433.132812 3) Program to find the area of the pentagon
Area of Pentagon = (5.0/2.0) * s * a = (5.0/2.0) * 13 * 5 = 162.5 4) Program to find the area of parallelogram
Area of Parallelogram = base * height; = 4 * 18 = 72 5) Program to find the area of square
Area of Square = a 6) Program to find the surface area of sphere
Volume = 4 * pie * (radius * radius); = 4 * 3.14 * 37 * 37 = 17210.285714 7) Program to find the volume of cone
Volume = pie * radius * radius * height/3; = 3.14 * 38 * 38 * 35/3 = 48766.666667 8) Program to find the volume of the cube
Volume of cube = side 9) Program to find the volume of cylinder
Volume of the cylinder = pie * radius 10) Program to calculate the CGPA percentage CGPA percentage is = (float)(9.5 * (CGPA));
CGPA percentage is = 86.070000 11) Program to convert Celsius into Fahrenheit Temperature in Fahrenheit = ((celsius * 9) / 5) + 32
Temperature in Fahrenheit = 53.6 12) Program to convert days into years
Number of years = days / 365; = 799 / 365 = 2 13) Program to convert Fahrenheit into Celsius Temperature in Celsius = ((Fahrenheit-32)*5)/9
Temperature in Celsius= ((54-32)*5)/9 = 12.22222 14) Program to find the area of an equilateral triangle
Area of Equilateral Triangle = ( 1.73 * a * a) / 4 = ( 1.73 * 5 * 5) / 4 = 10.81250 15) Program to find the area of a triangle
Area of Triangle = (b * h) / 2 = (5 * 12) / 2 = 30.0 16) Program to find the area of the right angle triangle
Area of Triangle = (b * h) / 2 = (5 * 8) / 2 = 20.0 17) Program to find the perimeter of the rectangle
Perimeter of Rectangle = 2 * ( a + b); = 2 * (5 + 4) = 18.00000 18) Program to find the simple interest Simple Interest = (P × R × T) / 100
Simple Interest = 51000.000 19) Program to find the surface area of a cube Surface Area Of Cube = 6 ( a * a )
Surface Area Of Cube = 6 * 5 * 5=150.00000 20) Program to find the surface area of cuboid
Surface Area OfCuboid = 2 * (l * w+ w * h + h * l) = 2 * (2 * 3 + 3 * 5 + 5 * 2) = 62.00000 21) Program to find the surface area of the cylinder Surface Area of Cylinder = 2 Π (r + h)
Surface Area of Cylinder = 2 Π (r + h) Here, r = radius, h = height, and Π ( pie ) = 3.14 = 2 * 3.14 * ( 2.0 + 5.0) = 44.00000 ## Number Programs1) Program to Check Disarium number
1 2) Program to Check Happy number
8 3) Program to Check Harshad number A number is said to be the Harshad number if it is divisible by the sum of its digit.
156 is a Harshad number 4) Program to print all Disarium numbers between 1 to 100
Disarium numbers between 1 and 100 are: 1 2 3 4 5 6 7 8 9 89 5) Program to print all Happy numbers between 1 to 100
List of happy numbers between 1 and 100: 1 7 10 13 19 23 28 31 32 44 49 68 70 79 82 86 91 94 97 100 6) Program to print all Pronic numbers between 1 to 100 A number is said to be pronic number if it is a product of two consecutive numbers. For examples: 6 = 2 x 3
Pronic numbers between 1 and 100: 2 6 12 20 30 42 56 72 90 7) Program to determine whether a given number is a Deficient number 8) Program to determine whether a given number is an abundant number 9) Program to determine whether a given number is a twisted prime number 10) Program to print all abundant numbers between 1 to 100 11) Program to print all Kaprekar numbers between 1 to 100 12) Program to print all prime numbers between 1 to 100 13) Program to print the average of n numbers 14) Program to print the combination (nCr) of the given number 15) Program to print the first 10 prime numbers 16) Program to print the permutation (nPr) of the given number 17) Program to print the sum of digits without using modulus 18) Program to swap two numbers 19) Program to swap two numbers without using the third variable ## Array Programs1) Program to copy all the elements of one array into another array
Elements of original array: 1 2 3 4 5 Elements of new array: 1 2 3 4 5 2) Program to find the frequency of each element of an array
Element | Frequency 1|2 2|4 8|1 3|1 5|1 3) Program to left rotate the elements of an array
Original array: 1 2 3 4 5 Array after left rotation: 4 5 1 2 3 4) Program to print the duplicate elements of an array
Duplicate elements in given array: 2 3 8 5) Program to print the elements of an array
Elements of given array: 1 2 3 4 5 6) Program to print the elements of an array in reverse order
Original array: 1 2 3 4 5 Array in reverse order: 5 4 3 2 1 7) Program to print the elements of an array present on even position
Elements of given array present on even position: 2 4 8) Program to print the elements of an array present on odd position
Elements of given array present on odd position: 1 3 5 9) Program to print the largest element present in an array
Largest element present in given array: 75 10) Program to print the number of elements present in an array
Number of elements present in given array: 5 11) Program to print the smallest element present in an array
Smallest element present in given array: 7 12) Program to print the sum of all the elements of an array
Sum of all the elements of an array: 15 13) Program to right rotate the elements of an array
Original array: 1 2 3 4 5 Array after right rotation: 3 4 5 1 2 14) Program to sort the elements of an array in ascending order
Elements of original array: 5 2 8 7 1 Elements of array sorted in ascending order: 1 2 5 7 8 15) Program to sort the elements of an array in descending order
Elements of original array: 5 2 8 7 1 Elements of array sorted in descending order: 8 7 5 2 1 ## Matrix Programs1) Program to calculate the addition of 2 matrices
Addition of two matrices: [2 1 2] [6 8 7] [2 7 4] 2) Program to calculate the subtraction of 2 matrices
Subtraction of two matrices: [2 5 3] [1 1 0] [0 1 2] 3) Program to determine whether a given matrix is an identity matrix
Given matrix is an identity matrix 4) Program to determine whether a given matrix is a sparse matrix
Given matrix is a sparse matrix 5) Program to determine whether two matrices are equal
Matrices are equal 6) Program to display the lower triangular matrix
Lower triangular matrix: [1 0 0] [8 6 0] [4 5 6] 7) Program to display the upper triangular matrix
Upper triangular matrix: [1 2 3] [0 6 4] [0 0 6] 8) Program to find the frequency of odd & even numbers in the given Matrix
Frequency of odd numbers: 5 Frequency of even numbers: 4 9) Program to find the product of two matrices
Product of two matrices: [7 7 6] [8 6 5] [6 7 5] 10) Program to find the sum of each row and each column of a matrix
Sum of 1 row: 6 Sum of 2 row: 15 Sum of 3 row: 24 Sum of 1 column: 12 Sum of 2 column: 15 Sum of 3 column: 18 11) Program to find the transpose of a given matrix
Transpose of given matrix: [1 4 7] [2 5 8] [3 6 9] ## String Programs1) Program to count the total number of punctuation characters exists in a string
If any character in the string is matched with ('!', "," ,"\'" ,";" ,"\"", ".", "-" ,"?"), increment the count by 1. Total number of punctuation characters exists in string: 4 2) Program to count the total number of vowels and consonants in a string
vowels = a, e, i, o, u consonants = b, c, d, f, g, h, j, k, l, m, n, p, q, r, s, t, v, w, x, y, z 3) Program to determine whether two strings are the anagram
Two Strings are called the anagram if they contain the same characters. However, the order or sequence of the characters can be different. str1 = "Grab"; str2 = "Brag";
Both the strings are anagram. 4) Program to divide a string in 'N' equal parts
Equal parts of given string are aaaa bbbb cccc 5) Program to find all the permutations of a string
All the permutations of the string are: ABC ACB BAC BCA CBA CAB 6) Program to find all possible subsets of a string
All subsets for given string are: A AB ABC B BC C 7) Program to find the longest repeating sequence in a string
Longest repeating sequence: bdf 8) Program to remove all the white spaces from a string
String after removing all the white spaces : Removewhitespaces 9) Program to replace lower-case characters with upper-case and vice versa
String after case conversion : gREAT pOWER 10) Program to replace the spaces of a string with a specific character
String after replacing spaces with given character: Once-in-a-blue-moon 11) Program to Count the Total Number of Characters in a String
Total number of characters in a string: 19 12) Program to Count the Total Number of Words in a String
Total number of words in the given string: 7 13) Program to Determine Whether a Given String is Palindrome
Given string is palindrome. 14) Program to Determine Whether One String is a Rotation of Another
Second string is a rotation of first string. 15) Program to Find Maximum and Minimum Occurring Character in a String
Minimum occurring character: a Maximum occurring character: e 16) Program to Find Reverse of a String
Original string: Dream big Reverse of given string: gib maerD 17) Program to Find the Duplicate Characters in a String
Duplicate characters in a given string: r e t s i 18) Program to Find the Duplicate Words in a String
Duplicate words in a given string: big black 19) Program to Find the Frequency of Characters
Characters and their corresponding frequencies p-2 i-1 c-2 t-2 u-1 r-2 e-3 f-1 20) Program to Find the Largest and Smallest Word in a String
Smallest word: an Largest word: extraordinary 21) Program to Find the Most Repeated Word in a Text File
The term "computer" is derived from Latin word "computare" which means to calculate. Computer is a programmable electronic device. Computer accepts raw data as input and processes it with set of instructions to produce result as output. The history of computer begins with the birth of abacus which is believed to be the first computer.
Most repeated word: computer 22) Program to Find the Number of Words in the Given Text File
The term "computer" is derived from Latin word "computare" which means to calculate. Computer is a programmable electronic device. Computer accepts raw data as input and processes it with set of instructions to produce result as output. The history of computer begins with the birth of abacus which is believed to be the first computer.
Number of words present in given file: 117 23) Program to Print Smallest and Biggest Possible Palindrome Word in a Given String
Smallest palindromic word: wow Biggest palindromic word: kayak 24) Program to Separate the Individual Characters from a String
Individual characters from given string: characters 25) Program to Swap two String Variables Without Using Third or Temp Variable
Strings before swapping: Good morning Strings after swapping: morning Good ## Pattern Programs1) Program To Print Following Pattern 2) Program To Print Following Pattern 5432* 3) Program To Print Following Pattern *000*000* 4) Program To Print Following Pattern 1 5) Program To Print Following Pattern 6) Program To Print Following Pattern 7) Program To Print Following Pattern 12344321 8) Program To Print Following Pattern 9) Program To Print Following Pattern 0 10) Program to Print Following Pattern 11) Program to Print Following Pattern A 12) Program to Print Following Pattern 13) Program to Print Following Pattern 1 2 3 4 5 14) Program to Print Following Pattern 15) Program to Print Following Pattern 16) Program to Print Following Pattern 17) Program to Print Following Pattern 1 18) Program to Print Following Pattern 1 19) Program to Print Following Pattern ## Tree Programs
OddLevelSum = 1 + 4 + 5 + 6 = 16 EvenLevelSum = 2 + 3 = 5 Difference = |16 - 5| = 11 2) Program to Construct a Binary Search Tree and Perform Deletion and Inorder Traversal
Binary search tree after insertion: 10 30 50 60 70 90 Binary search tree after deleting node 90: 10 30 50 60 70 Binary search tree after deleting node 30: 10 50 60 70 Binary search tree after deleting node 50: 10 60 70 3) Program to Convert Binary Tree to Binary Search Tree
Inorder representation of binary tree: 4 2 5 1 6 3 7 Inorder representation of resulting binary search tree: 1 2 3 4 5 6 7 4) Program to Determine Whether all Leaves are at Same Level
All leaves are at same level 5) Program to Determine Whether two Trees are Identical
Both the binary trees are identical 6) Program to Find Maximum Width of a Binary Tree
Maximum width of the binary tree: 4 7) Program to Find the Largest Element in a Binary Tree
Largest element in the binary tree: 74 8) Program to Find the Maximum Depth or Height of a Tree
Maximum height of given binary tree: 5 9) Program to Find the Nodes Which are at the Maximum Distance in a Binary Tree
Nodes which are at maximum distance: ( 4,9 ) ( 5,9 ) 10) Program to Find the Smallest Element in a Binary Tree
Smallest element in the binary tree: 1 11) Program to Find the Sum of all the Nodes of a Binary Tree
Sum of all nodes of binary tree: 31 12) Program to Find the Total Number of Possible Binary Search Trees with N Keys
Total number of possible Binary Search Trees with given key: 42 13) Program to Implement Binary Tree using the Linked List
Binary tree after insertion: 1 Binary tree after insertion: 2 1 3 Binary tree after insertion: 4 2 5 1 3 Binary tree after insertion: 4 2 5 1 6 3 7 14) Program to Search a Node in a Binary Tree
Search for node 5 in the binary tree
Element is present in the binary tree ## Singly Linked List Programs1) Singly Linked List Examples
100 200 300 2) Program to create and display a singly linked list
Nodes of singly linked list: 1 2 3 4 3) Program to create a singly linked list of n nodes and count the number of nodes
Nodes of singly linked list: 1 2 3 4 Count of nodes present in the list: 4 4) Program to create a singly linked list of n nodes and display it in reverse order
Original List: 1 2 3 4 Reversed List: 4 3 2 1 5) Program to delete a new node from the beginning of the singly linked list
Original List: 1 2 3 4 Updated List: 2 3 4 Updated List: 3 4 Updated List: 4 Updated List: List is empty 6) Program to delete a new node from the middle of the singly linked list
Original List: 1 2 3 4 Updated List: 1 3 4 Updated List: 1 4 Updated List: 4 Updated List: List is empty 7) Program to delete a node from the end of the singly linked list
Original List: 1 2 3 4 Updated List: 1 2 3 Updated List: 1 2 Updated List: 1 Updated List: List is empty 8) Program to determine whether a singly linked list is the palindrome
Nodes of the singly linked list: 1 2 3 2 1 Given singly linked list is a palindrome 9) Program to find the maximum and minimum value node from a singly linked list
Minimum value node in the list: 1 Maximum value node in the list: 8 10) Program to insert a new node at the middle of the singly linked list
Original list: 1 2 Updated List: 1 3 2 Updated List: 1 3 4 2 11) Program to insert a new node at the beginning of the singly linked list
Adding nodes to the start of the list: 1 Adding nodes to the start of the list: 2 1 Adding nodes to the start of the list: 3 2 1 Adding nodes to the start of the list: 4 3 2 1 12) Program to insert a new node at the end of the singly linked list
Adding nodes to the end of the list: 1 Adding nodes to the end of the list: 1 2 Adding nodes to the end of the list: 1 2 3 Adding nodes to the end of the list: 1 2 3 4 13) Program to remove duplicate elements from a singly linked list
Originals list: 1 2 3 2 2 4 1 List after removing duplicates: 1 2 3 4 14) Program to search an element in a singly linked list
Element is present in the list at the position : 2 Element is not present in the list 15) Program to sort the elements of the singly linked list
Original list: 9 7 2 5 4 Sorted list: 2 4 5 7 9 16) Program to swap nodes in a singly linked list without swapping data
Original list: 1 2 3 4 5 List after swapping nodes: 1 5 3 4 2 17) Program to swap the last element of the singly linked list from the first one
Originals list: 1 2 3 4 List after swapping the first node with last: 4 2 3 1 ## Circular Linked List Programs1) Program to Create a Circular Linked List of N Nodes and Count the Number of Nodes
Count of nodes present in circular linked list: 6 2) Program to Create a Circular Linked List of N Nodes and Display it in Reverse Order
Original List: 1 2 3 4 5 6 Reversed List: 6 5 4 3 2 1 3) Program to Create and Display a Circular Linked List
Nodes of the circular linked list: 1 2 3 4 4) Program to Delete a New Node From the Beginning of the Circular Linked List
Original List:1 2 3 4 Updated List:2 3 4 Updated List:3 4 Updated List:4 Updated List: List is empty 5) Program to Delete a New Node From the End of the Circular Linked List
Original List:1 2 3 4 Updated List:1 2 3 Updated List:1 2 Updated List:1 Updated List: List is empty 6) Program to Delete a New Node From the Middle of the Circular Linked List
Original List:1 2 3 4 Updated List:1 3 4 Updated List:1 4 Updated List:4 Updated List: List is empty 7) Program to Find the Maximum and Minimum Value Node From a Circular Linked List
Minimum value node in the list: 1 Maximum value node in the list: 20 8) Program to Insert a New Node at the Beginning of the Circular Linked List
Adding nodes to the start of the list: 1 Adding nodes to the start of the list: 2 1 Adding nodes to the start of the list: 3 2 1 Adding nodes to the start of the list: 4 3 2 1 9) Program to Insert a New Node at the End of the Circular Linked List
Adding nodes to the end of the list: 1 Adding nodes to the end of the list: 1 2 Adding nodes to the end of the list: 1 2 3 Adding nodes to the end of the list: 1 2 3 4 10) Program to Insert a New Node at the Middle of the Circular Linked List
Original list: 1 2 3 4 Updated List: 1 2 5 3 4 Updated List: 1 2 5 6 3 4 11) Program to Remove Duplicate Elements From a Circular Linked List
Originals list:1 2 3 2 2 4 List after removing duplicates:1 2 3 4 12) Program to Search an Element in a Circular Linked List
Element is present in the list at the position : 2 Element is not present in the list 13) Program to Sort the Elements of the Circular Linked List
Original list:70 90 20 100 50 Sorted list:20 50 70 90 100 ## Doubly Linked List Programs1) Program to Convert a Given Binary Tree to Doubly Linked List
Nodes of generated doubly linked list: 4 2 5 1 6 3 7 2) Program to Create a Doubly Linked List From a Ternary Tree
Nodes of the generated doubly linked list: 5 10 20 40 50 12 24 36 48 15 30 45 60 3) Program to Create a Doubly Linked List of N Nodes and Count the Number of Nodes
Nodes of doubly linked list: 1 2 3 4 5 Count of nodes present in the list: 5 4) Program to Create a Doubly Linked List of N Nodes and Display it in Reverse Order
Original List: 1 2 3 4 5 Reversed List: 5 4 3 2 1 5) Program to Create and Display a Doubly Linked List
Nodes of doubly linked list: 1 2 3 4 5 6) Program to Delete a New Node From the Beginning of the Doubly Linked List
Original List: 1 2 3 4 5 Updated List: 2 3 4 5 Updated List: 3 4 5 Updated List: 4 5 Updated List: 5 Updated List: List is empty 7) Program to Delete a New Node From the End of the Doubly Linked List
Original List: 1 2 3 4 5 Updated List: 1 2 3 4 Updated List: 1 2 3 Updated List: 1 2 Updated List: 1 Updated List: List is empty 8) Program to Delete a New Node From the Middle of the Doubly Linked List
Original List: 1 2 3 4 5 Updated List: 1 2 4 5 Updated List: 1 4 5 Updated List: 1 5 Updated List: 5 Updated List: List is empty 9) Program to Find the Maximum and Minimum Value Node From a Doubly Linked List
Minimum value node in the list: 1 Maximum value node in the list: 9 10) Program to Insert a New Node at the Beginning of the Doubly Linked List
Adding a node to the start of the list: 1 Adding a node to the start of the list: 2 1 Adding a node to the start of the list: 3 2 1 Adding a node to the start of the list: 4 3 2 1 Adding a node to the start of the list: 5 4 3 2 1 11) Program to Insert a New Node at the End of Doubly Linked List
Adding a node to the end of the list: 1 Adding a node to the end of the list: 1 2 Adding a node to the end of the list: 1 2 3 Adding a node to the end of the list: 1 2 3 4 Adding a node to the end of the list: 1 2 3 4 5 12) Program to Insert a New Node at the Middle of Doubly Linked List
Original list: 1 2 Updated List: 1 3 2 Updated List: 1 3 4 2 Updated List: 1 3 5 4 2 13) Program to Remove Duplicate Elements From a Doubly Linked List
Originals list: 1 2 3 2 2 4 5 3 List after removing duplicates: 1 2 3 4 5 14) Program to Rotate Doubly Linked List by N Nodes
Original List: 1 2 3 4 5 Updated List: 4 5 1 2 3 15) Program to Search an Element in a Doubly Linked List
Node is present in the list at the position : 3 Node is not present in the list 16) Program to Sort the Elements of the Doubly Linked List
Original list: 7 1 4 5 2 Sorted list: 1 2 4 5 7 ## MiscellaneousProgram to Convert cm to Feet and Inches Program to Convert Feet to Inches Program to Convert Inches to cm Program to Convert Inches to Feet Program to Convert Kilometer to cm Program to calculate Volume of Cone Write a Program to calculate the Perimeter of Hexagon Write a Program to calculate the Area of Rhombus Write a Program to calculate the surface Area of Cone Write a Program to calculate the Surface Area of Hemisphere Write a Program to find the Perimeter of Ellipse Write a program to calculate the Altitude of Isosceles Triangle Write a Program to calculate the Area of Isosceles Triangle Write a program to find the Volume of Tetrahedron Write a program to find the Area of an Icosahedron Write a program to find the Volume of Octahedron Write a program to find the Area of Tetrahedron Write a program to find the Surface Area of the Pentagonal Prism Write a program to find the Area of the Rectangular Prism Write a program to find the Surface Area of a Triangular Prism Write a Program to find the Area of Hexagonal Prism Write a Program to find the Volume of a Hexagonal Prism Write a program to find the Volume of the Rectangular Prism Program to Convert centimeter to millimeter Program to Convert centimeter to meter Program to Convert Feet to millimeter Program to Convert Meter to Centimeter Program to Convert millimeter to Feet Program to Convert Inches to meter Program to Convert Inches to mm Program to Convert m to Feet and Inches Write a program to calculate the Perimeter of a Rhombus Write a program to find the quotient and remainder Program to convert Kilobytes to bytes and bits Program to find the area and perimeter of the semicircle Program to find the area and perimeter of trapezium Program to find the type of triangle from the given coordinates Program to convert hours into minutes and seconds Program to convert temperature degree from Celsius to Kelvin Write a program to find the sum of even numbers |

For Videos Join Our Youtube Channel: Join Now

- Send your Feedback to [email protected]