forked from yashhere/git-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpalindrome.c
More file actions
35 lines (25 loc) · 685 Bytes
/
palindrome.c
File metadata and controls
35 lines (25 loc) · 685 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
/*********
Author1 Name:
Author2 Name:
FIXED THE BUGS FOR GIT-WORKSHOP
**********/
#include <stdio.h>
int main()
{
int n, reversedInteger = 0, remainder, originalInteger;
printf("Enter an integer: ");
scanf("%d", &n);
originalInteger = n;
while( n!=0 )
{
remainder = n%10;
reversedInteger = reversedInteger*10 + remainder;
// HERE IS THE BUG, THE BELOW LINE SHOULD BE UNCOMMENTED FOR THIS PROGRAM TO WORK PROPERLY
// n /= 10;
}
if (originalInteger == reversedInteger)
printf("%d is a palindrome.", originalInteger);
else
printf("%d is not a palindrome.", originalInteger);
return 0;
}