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

All Programs Must Have: Header Comments and Inline Comments Consistent Indentati

ID: 3586446 • Letter: A

Question

All Programs Must Have: Header Comments and Inline Comments Consistent Indentation and Spacing See the Documentation and Style Guidelines. All programs must compile. grade of zero. Programs that do not compile will receive a Lab 4 More with Strings .Make a new folder for lab4. write this in C. Create a header file functions4.h with the prototypes for the two functions shown below Include a preprocessor wrapper 1. void splitAlpha const char original, charlower, char *upper The variables original, lower, and upper are pointers to null-terminated strings (character arrays)The function splitAlpha should copy the lowercase letters from original to lower, and the uppercase letters from original tupper. The memory areas pointed to by lower and upper are assumed to be large enough to hold the number of characters that need to be moved The string original may contain non-alphabetic characters. The contents of original shuld not be changed. For example, if original contains The symbol for Intel is INTC." After the function completes, lower should contain "hesymbolforntelis" (remember to put in the nll character) and upper should contain "TIINTC" (null character at the end)

Explanation / Answer

function4.c

#include<stdio.h>
#include<string.h>

void splitAlpha(const char *original, char *lower, char *upper){

   int i,j,k;
   j = 0;
   k = 0;
   for (i = 0; i<strlen(original); i++){
       if (original[i] >= 'a' && original[i] <= 'z'){

          lower[j]=original[i];
          j++;
       }
       if (original[i] >= 'A' && original[i] <= 'Z'){

          upper[k]=original[i];
          k++;         
       }
   }
   lower[j] = '';
   upper[k] = '';

}

void printSequences(const char *text){

    int i;
    int seq;

    for (i = 0; i<strlen(text); i++){
         if (i+1 <strlen(text)){
            if (text[i+1] == text[i]+1){
               seq = 1;
               printf("%c",text[i]);
            }
            else {
               if (seq == 1){
                 printf("%c ",text[i]);
                 seq = 0;
               }     
            }
         }
    }
    if (seq == 1){
       printf("%c",text[i-1]);
    }
}

lab4.c

int main(){

   char str[] = "The symbol for Intel is INTC.";
   char str1[] = "ab123@XY";
  
  
   char lower[50];
   char upper[50];
   splitAlpha(str,lower,upper);
   printf("%s ", lower);
   printf("%s ", upper);
  
   printSequences(str1);
   return 0;
}

makefile

lab4: function4.c lab4.c
        gcc -o lab4 function4.c lab4.c

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