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

I want this programs written in C Write a function that, given a string, a width

ID: 3691872 • Letter: I

Question

I want this programs written in C Write a function that, given a string, a width, and an empty string for output, centers the string in the output area. The function is return 1if the formatting is successful and 0 if any errors, such as string length greater than width, are found. Write a function called new Strcpy that does the same job as strcpy. The declaration for your function is to be the same as the library function. Write a function called newStrCat that does the same job as strcat. The declaration for your function is to be the same as the library function. Write a function called newStrCmp that does the same job as strcmp. The declaration for your function is to be the same as the library function. A string is a palindrome if it can be read forward and backward with the same meaning. Capitalization and spacing are ignored. For example, anna and go dog are palindromes. Write a function that accepts a string and returns true if the string is a palindrome and false if it is not. Test your function with the following two palindromes and at least one case that is not a palindrome: Madam, I'm Adam Able was I ere J saw Elba

Explanation / Answer

32.

----------------------------------------------

#include <stdio.h>
#include<string.h>
int format(char str[],int width)
{
    if(strlen(str)>width)
    return 0;
    printf ("%*s ", width/2+strlen(str)/2,str);
    return 1;
}
int format(char[],int);
int main()
{
    char str[]="program";
    int width=20;
    format(str,width);
    return 0;
}

--------------------------------------------------

35.

int newStrCmp(char s1[], char s2[])
{
   int i = 0;
    while (s1[i] == s2[i])/*repeat loop until characters are equal*/
   {
      if (s1[i] == '' || s2[i] == '')/*if either string reach end exit loop*/
         break;
      i++;
   }

   if (s1[i] == '' && s2[i] == '')
      return 0;
   else
      return s1[i]-s2[i];/*return difference between the first occured different characters*/
}


--------------------------------------------------

36.

#include <stdio.h>
#include <ctype.h>
#include <string.h>
void strlwr(char str[])
{
for(int i = 0; i < strlen(str)-1; i++)
str[i] = tolower(str[i]);
}
int isPalindrome(char string[])
{
int high = strlen(string) - 1;
int low = 0;
strlwr(string);
while(low < high)
{
if(string[low] == string[high])
{
low++;
high--;
continue;
}
else if(string[low] == ' ')
low++;
else if(string[high] == ' ')
high--;
else
return 0;   
}
return 1;
}
int main()
{
char str[50];
printf("Enter the string: ");
scanf("%s", str);
printf("Palindrome: %i ", isPalindrome(str));
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote