+1 714-215-3097

(Solved) : Write C Program Given Template Please Use Template Subject Passing Char Array Argument Acc Q35623418

Write a C Program by the given template (please use thattemplate)


Passing char array as argument, accessing argument array.Pointer notion in place of array index notation.


Write an C program that reads inputs line by line, anddetermines whether each line of input forms a “case insensitive”palindrome. The program terminates when quit is read in.


Use the template to start with.

• Assume that each line of input contains at most 30 charactersbut it may contain blanks.

• Use fgets to read line by line

  • note that the line that is read in using fgets will contain anew line character ‘n’, right before ”. Then you either need toexclude it when processing the array, or, remove the trailing newline character before processing the array. One common approach forthe latter is replacing the ‘n’ with ” (implemented foryou).

• Define a function void printReverse (char *) which prints theargument array reversely (implemented for you).

• Define a function int isPalindrome (char *) which determineswhether the argument array (string) is a case-insensitivepalindrome. “Dad” is a case-insensitive palindrome, like “dad”. Donot use array indexing [] throughout your implementation. Instead,use pointers and pointer arithmetic to manipulate the array.

• Do not create extra arrays. Manipulate the original arrayonly. Do not use global variables.

Sample Inputs/Outputs:



Not a case-insensitive palindrome



Is a case-insensitive palindrome.


Template code to follow:

#include <stdio.h>#include <string.h> #define SIZE 40 int isPalindrome (char *);void printReverse (char *); int main (){ int result; char c; int i; int count=0; char arr[SIZE]; fgets(arr,SIZE,stdin); while ( ) { arr[strlen(arr)-1] = ”; // remove the trailing n // print backward printReverse(arr); result = isPalindrome (arr); if (result==1) printf (“nIs a case-insensitive palindrome.nn”); else printf (“nNot a case-insensitive palindrome.nn”); fgets(arr,SIZE,stdin); } return 0;} int isPalindrome (char * str){} // assume the n was removed manuallyvoid printReverse(char * str){ int i = strlen(str) -1; while ( i >=0 ){ printf(“%c”, *(str+i) ); // or putchar(*(str+i)); i–; }}

Leave a Reply

Your email address will not be published. Required fields are marked *