Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

need help removing punctuation from the string this is the C code that I have #i

ID: 3755101 • Letter: N

Question

need help removing punctuation from the string this is the C code that I have

#include #include #include #include #include #include eint main() { char text[20], reverse text [20]; int i, n, t, c, length e, j 0; printf( "Please enter a string to check if it is a palindrome and press enter: "); fflush (stdout); fflush (stdin); scanf("%n]s", text); //Makes all lowercase for (int i - 0; text[i]; i++) f text[i] -tolower(text[i]); // Removes Spaces for (1-0; text [i] ++1) !- ') ' '; { if (text[i] l- text[j++]-text[i]; text[j]-'e'; //Remove punctuation //this will calculate the length of given text for (i; text[i] e'; i+) length++; //Reverse the original text and store into reverse_text for (i length - 1; 1 )s ; |--) { reverse_text[length - i - 1] - text[i],: //Check whether reverse_text is same to original text for (n 1, 1-0; 1

Explanation / Answer

//Remove Punctuation

j=0;
for(i=0;text[i]!='';++i)
if(!ispunct(text[i]))
text[j++]=text[i];
text[j]='';

Explanation: ispunct(char variable) is used to check if the passed value i spunctuation or not.