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

4: .Make a new folder for lab4 · write this in c. create a header file functions

ID: 3584839 • Letter: 4

Question

4: .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, chalower, charupper 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 to upper. 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 should 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 null character) and upper should contain "TIINTC" (null character at the end)

Explanation / Answer

PLEASE REFER BELOW CODE

1.)

#include<stdlib.h>
#include<stdio.h>


void splitAlpha(const char *original, char *lower, char *upper)
{
int i=0,lindex=0,uindex=0;
//loop until end of string
while(original[i] != '')
{
if(original[i] >= 'a' && original[i] <= 'z') //if character is lowercase
{
lower[lindex] = original[i];
lindex++;
i++;
}
else if(original[i] >= 'A' && original[i] <= 'Z') //if character is uppercase
{
upper[uindex] = original[i];
uindex++;
i++;
}
else
{
i++;
}
}
upper[uindex]='';
lower[lindex]='';
}
int main()
{
char original[100] = "The symbol for Intel is INTC.";
char lower[50];
char upper[50];
splitAlpha(original,lower,upper); //calling function
printf("%s ", original);
printf("%s ", lower);
printf("%s ", upper);
return 0;

}

PLEASE REFER BELOW OUTPUT

The symbol for Intel is INTC.
hesymbolforntelis
TIINTC

Process returned 0 (0x0) execution time : 0.032 s
Press any key to continue.

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

2)

PLEASE REFER BELOW CODE

#include<stdlib.h>
#include<stdio.h>
#include<stdbool.h>
#include <ctype.h>

//CHECKING CHARACTER IS LOWERCASE
bool islower1(char ch)
{
return (ch >= 'a' && ch <='z');
}
//CHECKING CHARACTER IS UPPERCASE
bool isupper1(char ch)
{
return (ch >= 'A' && ch <='Z');
}
void printSequences(const char *text)
{
char lower[50];
char upper[50];
char digit[50];

int i=1,lindex=0,uindex=0,dindex=0;
//LOOP UNTILL END OF STRING
while(text[i] != '')
{
if(islower1(text[i-1]) && islower1(text[i])) //IF CURRENT AND PREVIOUS CHARACTER IS LOWERCASE
{
lower[lindex] = text[i-1];
lindex++;
lower[lindex] = text[i];
lindex++;
i+=2;
}
else if(isupper1(text[i-1]) && isupper1(text[i])) //IF CURRENT AND PREVIOUS CHARACTER IS UPPERCASE
{
upper[uindex] = text[i-1];
uindex++;
upper[uindex] = text[i];
uindex++;
i+=2;
}
else if(isdigit(text[i-1]) && isdigit(text[i])) ////IF CURRENT AND PREVIOUS CHARACTER IS DIGIT
{
digit[dindex] = text[i-1];
digit[dindex] = text[i];
dindex++;
i++;
}
else
{
i++;
}
}
lower[lindex] = '';
upper[uindex] = '';
digit[dindex] = '';
//PRINTING SEQUENCE
printf("%s ", lower);
printf("%s ", digit);
printf("%s ", upper);

}

int main()
{
char text[100] = "abk123@XY";
printSequences(text);
return 0;
}

PLEASE REFER BELOW OUTPUT

ab
123
XY

Process returned 0 (0x0) execution time : 0.019 s
Press any key to continue.

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