Professional Documents
Culture Documents
#include <iostream>
#include <math.h>
using namespace std;
bool isPrime(int n)
{
if (n == 1)
return false;
#include <iostream>
using namespace std;
int main()
{
int n, num, digit, rev = 0;
cout << "Enter a positive number: ";
cin >> num;
n = num;
do
{
digit = num % 10;
rev = (rev * 10) + digit;
num = num / 10;
} while (num != 0);
cout << " The reverse of the number is: " << rev << endl;
if (n == rev)
cout << " The number is a palindrome.";
else
cout << " The number is not a palindrome.";
return 0;
}
OUTPUT :-
4) Program to check whether the given number is
Armstrong or not in c++.
#include <iostream>
using namespace std;
int main() {
int num, originalNum, remainder, result = 0;
cout << "Enter a three-digit integer: ";
cin >> num;
originalNum = num;
while (originalNum != 0) {
originalNum /= 10;
}
if (result == num)
cout << num << " is an Armstrong number.";
else
cout << num << " is not an Armstrong number.";
return 0;
}
OUTPUT :-
#include<iostream>
using namespace std;
int main()
{
int arr[5], i;
cout<<"Enter 5 Array Elements: ";
for(i=0; i<5; i++)
cin>>arr[i];
cout<<"\nThe Original Array is:\n";
for(i=0; i<5; i++)
cout<<arr[i]<<" ";
cout<<"\n\nThe Reverse of Given Array is:\n";
for(i=(5-1); i>=0; i--)
cout<<arr[i]<<" ";
cout<<endl;
return 0;
}
OUTPUT :-