C++ Programs
C++ programs are frequently asked in the interview. These programs can be asked from basics, array, string, pointer, linked list, file handling etc. Let’s see the list of top c++ programs.
1) Fibonacci Series
Write a c++ program to print fibonacci series without using recursion and using recursion.
Input: 10
Output: 0 1 1 2 3 5 8 13 21 34
2) Prime number
Write a c++ program to check prime number.
Input: 17
Output: not prime number
Input: 57
Output: prime number
3) Palindrome number
Write a c++ program to check palindrome number.
Input: 121
Output: not palindrome number
Input: 113
Output: palindrome number
4) Factorial
Write a c++ program to print factorial of a number.
Input: 5
Output: 120
Input: 6
Output: 720
5) Armstrong number
Write a c++ program to check armstrong number.
Input: 371
Output: armstrong
Input: 342
Output: not armstrong
6) Sum of Digits
Write a c++ program to print sum of digits.
Input: 23
Output: 5
Input: 624
Output: 12
7) Reverse Number
Write a c++ program to reverse given number.
Input: 234
Output: 432
8) Swap two numbers without using third variable
Write a c++ program to swap two numbers without using third variable.
Input: a=5 b=10
Output: a=10 b=5
9) Matrix Multiplication
Write a c++ program to print multiplication of 2 matrices.
Input:
first matrix elements: 1 2 3 1 2 3 1 2 3 second matrix elements 1 1 1 2 1 2 3 2 1
Output:
multiplication of the matrix: 14 9 8 14 9 8 14 9 8
10) Decimal to Binary
Write a c++ program to convert decimal number to binary.
Input: 9
Output: 1001
Input: 20
Output: 10100
11) Alphabet Triangle
Write a c++ program to print alphabet triangle.
Output:
A ABA ABCBA ABCDCBA ABCDEDCBA
12) Number Triangle
Write a c++ program to print number triangle.
Input: 7
Output:
enter the range= 6 1 121 12321 1234321 123454321 12345654321
13) Fibonacci Triangle
Write a c++ program to generate fibonacci triangle.
Input: 5
Output:
1 11 112 1123 11235
14) Number in Characters
Write a c++ program to convert number in characters.
Input: 74254
Output:Seven Four Two Five Four
Input: 203
Output: two zero three