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: 8
Output:1  1 2 3 5 8 13 21
Program details 



2) Prime number

Write a c++ program to check prime number.

Input: 17

Output: not prime number

Input: 57

Output: prime number

Program details 



3) Prime number up to N number

Write a program series of prime number up to N number using c++.


Input: 25

Output: 2 3 5 7 11 13 17 19 23

Program details 




4) Palindrome number

Write a c++ program to check palindrome number.

Input: 12421

Output: not palindrome number

Input: 113

Output: palindrome number

Program details 




5) Factorial

Write a c++ program to print factorial of a number.

Input: 5

Output: 120

Input: 6

Output: 720

Program details 



6) Armstrong number

Write a c++ program to check armstrong number.

Input: 371

Output: armstrong

Input: 342

Output: not armstrong
Program details 




7) Sum of Digits
Write a c++ program to print sum of digits.

Input: 23

Output: 5

Input: 624

Output: 12
Program details 




8) Reverse Number

Write a c++ program to reverse given number.

Input: 234

Output: 432
Program details 



9) 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
Program details 



10) 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

Program details 



11) Decimal to Binary

Write a c++ program to convert decimal number to binary.

Input: 9

Output: 1001

Input: 20

Output: 10100
Program details 



12) Alphabet Triangle

Write a c++ program to print alphabet triangle.

Output:

     A
    ABA
   ABCBA
  ABCDCBA
 ABCDEDCBA


Program details 




13) Number Triangle

Write a c++ program to print number triangle.

Input: 7

Output:

enter the range= 6

      1
     121
    12321
   1234321
  123454321
 12345654321






Home next 


No comments:

Post a Comment