-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.cpp
More file actions
45 lines (35 loc) · 707 Bytes
/
Copy pathcode.cpp
File metadata and controls
45 lines (35 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
using namespace std;
int main(void)
{
int sum = 0;
int size = 10;
int sumarr[] = {1,3,44,66,88,90,9,232,4325,2321};
for(int i = 0; i < size; i++){
sum = sum + sumarr[i];
}
int num = 45689;
int rev = 0;
int d = -1;
while( num > 0){
d = num % 10;
rev = rev*10 + d;
num = num / 10;
}
int arr[] = {1,2,3,4,5,4,3,2,1};
int beg = 0;
int end = 8;
int isPalindrome = 1;
while(beg < end){
if (arr[beg] != arr[end]){
isPalindrome = -1;
break;
}
beg++;
end--;
}
cout << "Sum: " << sum << endl;
cout << "Reversed Number: " << rev << endl;
cout << "Is Palindrome: " << isPalindrome << endl;
return 0;
}