Question
C Programming Question: - Create a header file named lab2functions.h. In this file, place the following lines: #ifndef LAB2FUNCTIONS #define LAB2FUNCTIONS // here is where
C Programming Question:
- Create a header file named lab2functions.h. In this file, place the following lines: #ifndef LAB2FUNCTIONS #define LAB2FUNCTIONS // here is where your 4 function prototypes will go #endif
Note: Program the functions simple.
Print a character array. Write a function called printCharArray that will print the elements of a char array, 10 per line. The characters should be separated by one space. The parameters to the function are: 1) an array of characters 2) the size of the array (of type size_t )
Count the number of letters in a character array. Write a function named countLetters that will count and return the number of letters (either uppercase or lowercase) that appear in the array. The parameters to the function are: 1) an array of characters 2) the size of the array (of type size_t )
Determine the number of elements that are the same in two arrays. Write a function named numMatches that compares the elements in two arrays and counts how many elements are the same. The function only compares array elements with the same index, array1[0] with array2[0], array1[1] with array2[1], etc. The arrays are assumed to have the same number of elements. The parameters to the function are: 1) the first array of characters 2) the second array of characters 3) the size of the arrays (of type size_t )
Replace all of the lowercase letters in the array with the corresponding capital letters. Write a function named capitalize that looks for lowercase letters in the array. When a lowercase letter is found, the array element should be changed to the corresponding capital letter. The parameters to the function are: 1) an array of characters 2) the size of the array (of type size_t )
- Create a source file named lab2functions.c. In this file, place the implementations (the full header and body) of the four functions above. lab2functions.c should NOT have a main function. Start the file with comments and an include:
// header comments
#include "lab2functions.h"
// implementation of printCharArray
// implementation of countLetters
// implementation of numMatches
// implementation of capitalize
- Create a test program named lab2.c. In this file, place the main function as follows:
// header comments
#include "lab2functions.h"
. h not .c
#include
#include
int main(void) {
// include statements to completely and thoroughly
// test the functions
// use print statements to clearly state which function
// is being tested, print the contents of array(s) before
// and (if needed) after function calls so one can see whether
// functions worked correctly or not
} // end function main
You may initialize arrays for testing in your code or you may prompt the user to enter array characters if you like.
In total there should be three different files. lab2functions.h | lab2functions.c | lab2.c
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started