All Programs Must Have Header Comments and Inline Comments Consistent Indentatio
ID: 3850160 • Letter: A
Question
All Programs Must Have Header Comments and Inline Comments Consistent Indentation and Spacing All programs must compile. Programs that do not compile will receive a grade of zero. Lab 4a: More with Strings Make a new folder for lab4a. Write this in C Create a header file functions4a.h with the prototypes for the two functions shown below. Include a preprocessor wrapper. 1. void split Alpha const char original, char lower char upper The variables original, lower, and upper are null-terminated strings The function splitAlpha should copy the lowercase letters from original to lower, and the uppercase letters from original to upper 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 should not be changed. For example, if original contains "The symbol for Intel is INTC." After the function completes, lower should contain "hesymbolforntelis" and upper should contain "TIINTC".Explanation / Answer
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void splitAlpha(const char * original,char * lower, char * upper);
void printSequences(const char * text);
int main()
{
char * lower;
char * upper;
splitAlpha("The symbol for Intel is INTS",lower,upper);
printSequences("abk123@XY");
return 0;
}
void printSequences(const char * text){
int len = strlen(text);
int i = 0;
int isSec=0;
for(i=0;i<len-1;i++){
if(text[i]==text[i+1]-1){
if(!isSec){
isSec =1;
printf("%c%c",text[i],text[i+1]);
}
else
printf("%c",text[i+1]);
continue;
}
if(isSec)
printf(" ");
isSec=0;
}
printf(" ");
}
void splitAlpha(const char * original,char * lower, char * upper){
int len = strlen(original);
int i=0;
upper = (char*)malloc(1);
lower = (char*)malloc(1);
for(i=0;i<len;i++){
if(original[i]>=97 &&original[i]<=112){
int length = strlen(lower);
char * temp = lower;
lower = (char*)malloc(length+2);
strcpy(lower,temp);
lower[length] = original[i];
lower[length+1]='';
}
if(original[i]>=65 &&original[i]<=90){
int length = strlen(upper);
char * temp = upper;
upper = (char*)malloc(length+2);
strcpy(upper,temp);
upper[length] = original[i];
upper[length+1]='';
}
}
printf("lower :%s upper : %s ",lower,upper);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.