Write the following program in C (not C++ or Java) For the following problems, c
ID: 3606935 • Letter: W
Question
Write the following program in C (not C++ or Java)
For the following problems, create one main program that will
create 4 sets of array of characters (one to be used for each function call)
populate each array with the same symbols,lowercase and uppercase letters and numbers.
print the elements of the array
call each of the functions using it’s own array
print the expected output (output varies depending on the function)
Functionality of the functions
Convert lowercase letters to uppercase letters and print the updated array
print the length of the array
print the resulting array containing only numbers
print the resulting array containing only lowecase letters
Explanation / Answer
#include <stdio.h>
//declaring all functions
int convertUpperCase(char input[],int len);
int findLegth(char input[]);
int findNumberArray(char input[],int len);
int findLowerCaseChar(char input[],int len);
int main()
{
//initialize array with symbal,lowercase,uppercase,digit
char str[] = "$cZ8";
// take point char to specify seperate function
char *findSmallChar;
char *findLegthOfTheArray;
char *findCapChar;
char *findDigitChar;
// assign char array to individual pointer
findSmallChar= str;
findLegthOfTheArray=str;
findCapChar=str;
findDigitChar=str;
// finding out the lenght of array
int len=findLegth(findLegthOfTheArray);
printf("The length of the array is :'%d'" ,len);
printf(" ");
// finding out the lower char in array
printf("The resulting array containing only lowecase letters are :");
findLowerCaseChar(findSmallChar,len);
printf(" ");
// converting lower case to upper case
convertUpperCase(findCapChar,len);
printf("Converted lowercase letters to uppercase letters and printing the updated array :");
for(int i = 0; i<len; i++)
{
printf( "%c", findCapChar[ i ]);
}
printf(" ");
// finding out the numbers in array
printf("The resulting array containing only numbers are :");
findNumberArray(findDigitChar,len);
printf(" ");
return 0;
}
// taking in argument as findCapChar array
int convertUpperCase(char input[],int len)
{
for(int i = 0;i<len; i++)
{
if(input[i]>=97 && input[i]<=122)
{
input[i]=input[i]-32;
}
}
}
// taking in argument as findLegthOfTheArray array
int findLegth(char input[])
{
int temp=0;
while(input[temp] != '')
{
++temp;
}
return temp;
}
// taking in argument as findDigitChar array
int findNumberArray(char input[],int len)
{
for(int i = 0; i<len; i++)
{
if(input[i] >= 48 && input[i] <= 57)
{
printf("%c", input[i]);
}
}
}
// taking in argument as findSmallChar array
int findLowerCaseChar(char input[],int len)
{
for(int i = 0; i<len; i++)
{
if((input[i] >= 97 && input[i] <= 122) )
{
printf("%c", input[i]);
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.