Generation

generate functionSat, 24 Jun 2023

Crear un programa que compruebe si un texto ingresado por teclado es o no un palindromo

char *reverse(char *str) { int i, j; char *begin_ptr, *end_ptr, ch; begin_ptr = str; end_ptr = str; while (*end_ptr != '\0') { end_ptr++; } end_ptr--; for (i = 0; i < (end_ptr - begin_ptr) / 2; i++) { ch = *end_ptr; *end_ptr = *begin_ptr; *begin_ptr = ch; begin_ptr++; end_ptr--; } return str; } int main() { char str[100]; char *rev; printf("Enter the string to check if it is a palindrome\n"); scanf("%s", str); rev = reverse(str); if (strcmp(rev, str) == 0) { printf("%s is a palindrome\n", str); } else {

Questions about programming?Chat with your personal AI assistant