# C++ Programming Code Examples

## C++ > For Loops and While Loops Code Examples

### Initializing each element separately in the loop:

Finds Path Between Two Nodes in a Graph -
A C++ Program to "check and find" if the path between two nodes exists. By running "DFS" on given graph we can find out whether path exists between two nodes. Class represents a

C Program code to Multiply two Matrices -
Read elements in two matrices and multiply them. Matrix multiplication program in C. How to multiply matrices in C programming. Input elements in first matrix from user and...

Find the Nearest Common Ancestor in The -
C Program prints all the elements of Nth level in single line. Structure of binary tree node. Add node to binary tree. Height of the binary tree. Finds the nearest common ancestor. If

Check Prime or Armstrong Number Using -
In this program, two User-Defined functions checkPrimeNum() & checkArmstrongNum() are created. The checkPrimeNum() returns 1 if the number entered by the user is a Prime

C++ Code for Two Dimensional (2D) Array -
"Two dimensional" (2D) array can be made in C++ Language by using two for loops, first is outer for loop and the second one is inner for loop. Outer for Loop is responsible for rows

C Trim Leading White Spaces from Strings -
Program Trim leading white space characters from a string. Remove "Leading Whitespace" characters from the string. Find Last index of whitespace character. White space character

C++ Code Find Largest of Three Numbers -
To find the largest number among the three numbers in C++, enter three numbers, now checking which one is the "largest number". After finding the largest number, we display

Check a Given Number is Perfect Number -
This C program code checks whether a given number is perfect number. Perfect number is a number which is equal to sum of its divisor. For eg,divisors of 6 are 1,2 and 3. The sum of