# C++ Programming Code Examples

## C++ > Pyramid Patterns Code Examples

### C++ Program for Print Pascal Triangle Pattern

Find last Occurrence of Character in String -
C program to input any String from user and find the Last occurrence of a given character in the string. Input String from user, 'Store it' in some variable say 'str'. Declare a index =-1

C++ Program Finds HCF of Two Numbers -
To find the HCF ('Highest Common Factor') or GCD (Greatest Common Divisor) of 2 or more numbers, make prime factors of the numbers and choose the common prime factors. Then

Finds Greater Number of Entered Number -
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

Convert Octal Number Decimal Vice Versa -
In the program, the octal number is stored in the variable octalNumber, passed to function octalToDecimal(). This function converts the octal number passed by user to its equivalent

C++ Program Codes Swaps Two Numbers -
The first program uses temporary variable to swap numbers, whereas the second program doesn't use temporary variables. To perform 'swapping' in above example, three variables

Use Infinite While Loops in C++ Language -
This Loop would never end as 'decrementing' the value of i which is 1 so the condition i<=6 would never return false. A "While Loop" that never stops is said to be "Infinite While Loop",

Code find power of number using for loop -
C program to find power of a number using for loop. Input base and exponents from user. Store it in two variables say base and expo. Declare & initialize another variable to store

Code Find sum of Upper Triangular matrix -
Sum of upper triangular matrix is denoted with below image. In below image we need to find sum of matrix elements inside the red triangle. C program to read elements in a...