A couple of points.
1. You need to move bits of code into functions.
> "Write two functions int is_square(int num) and int reverse(int num)"
2. Indentation matters - yes, really!
Code:
#include<stdio.h>
int main()
{
int a, b, sum, rev = 0, remainder, i;
printf("Please enter the two integers:");
scanf("%d%d", &a, &b);
sum = a + b;
while (sum != 0) {
remainder = sum % 10;
rev = rev * 10 + remainder;
sum /= 10;
}
for (i = 0; i <= sum; i++) {
if (sum == i * i) {
printf("Alice wins");
} else if (rev == i * i) {
printf("Bob wins");
}
return 0;
}
}
So for example
- you mess up the sum value, trying to compute the rev value.
- your return 0; is inside the for loop, so your loop runs only once anyway.
- Alice always wins, because you managed to make sum = 0 trying to compute rev.