# C++ Programming Code Examples

## C++ > Beginners Lab Assignments Code Examples

### CGI program using C++ Programming

C Add Two Distances (in inch-feet) System -
In this c program code, a structure Distance is defined. The structure has two members inch (a float) and feet (an integer). Two variables (distance1 and distance2) are created which...

Implement Two Stacks using Single Array -
C Programming code implements two Stacks using a Single Array & Check for Overflow & Underflow. A Stack is a linear data structure in which a data item is inserted and deleted...

Count Frequency of each Element in Array -
C programming code to read elements in an array and find frequency of each element in an array. C Program to count the occurrence of each element in an array. Logic to count...

C++ Check a Number is Palindrome or not -
Palindrome number is a number that remains the same when its digits are reversed. 16461, for example: we take 121 and reverse it, after revers it is same as original. Get a value from

C Coding Check the Character is Alphabet -
If the ASCII value of the character entered by the user lies in the range 97 to 122 or from 65 to 90, that number is an alphabet. 'a' is used instead of 97 and 'z' is used instead of 122. 'A'

Code Toggle or Invert nth Bit of a number -
C program code input any number from user and toggle or invert or flip nth bit of the given number using bitwise operator. Toggling bit means setting a bit in its complement state.

Swapping Two Numbers Without Variable -
Imagine we have two number 1 and 2 stored in x and j respectively now. If we add x and j (1 + 2) and store it to x then x will become 3 and j is still 2. We subtract j (2) from new value of

C Program to calculate Area of a Polygon -
Given the coordinates of the vertices of a convex polygon, calculate its area and perimeter. Subdivide it into triangles and calculate the area of each triangle with the