My issue
#include<stdio.h>
#include<string.h>
int is_palindrome(char str)
{
int len = strlen(str);
int start = 0;
int end = len-1;
while(start<end)
{
if(str[start]!=str[end])
{
return 0;
}
start++;
end–;
}
return 1;
}
int main()
{
char str[100];
int num_cases;
scanf(“%d”, &num_cases);
for(int i = 0; i < num_cases; i++)
{
scanf(“%s”,str);
}
if(is_palindrome(str))
{
printf(“Palindrome \n”);
}
else
{
printf(“Not Palindrome \n”);
}
return 0;
}
My code
#include<stdio.h>
#include<string.h>
int is_palindrome(char str[])
{
int len = strlen(str);
int start = 0;
int end = len-1;
while(start<end)
{
if(str[start]!=str[end])
{
return 0;
}
start++;
end--;
}
return 1;
}
int main()
{
char str[100];
int num_cases;
scanf("%d", &num_cases);
for(int i = 0; i < num_cases; i++)
{
scanf("%s",str);
}
if(is_palindrome(str))
{
printf("Palindrome \n");
}
else
{
printf("Not Palindrome \n");
}
return 0;
}
Learning course: Algorithmic Problem Solving
Problem Link: https://www.codechef.com/learn/course/klu-problem-solving/KLUPS00A/problems/LPYAS156