EXERCISE NAME: Using 2D char Array Given the following source code: #include int count_digits(char* text); int main(void) { char* test[] = { "H3ll0", // 2 digits "Qu3sti0n 3...", // 3 digits "0ld Pr4ctic4l T3st", // 4 digits "is", // 0 digits "e4sy!" // 1 digit }; for (int k = 0; k < 5; ++k) { printf("%s : ", test[k]); printf("%d digits\n", count_digits(test[k])); } return 0; } int count_digits(char* text) { // TODO: Insert your code here... // TODO: Temporary stub return... return 0; } Write the source code to count the number of digits in the C-String passed into the count_digits function. Follow good programming standards for whitespace, naming and commenting. Test your program to ensure the implementation is robust and the program correctly outputs the number of digits in each C-String.
EXERCISE NAME: Using 2D char Array
Given the following source code:
#include <stdio.h>
int count_digits(char* text);
int main(void)
{
char* test[] =
{
"H3ll0", // 2 digits
"Qu3sti0n 3...", // 3 digits
"0ld Pr4ctic4l T3st", // 4 digits
"is", // 0 digits
"e4sy!" // 1 digit
};
for (int k = 0; k < 5; ++k)
{
printf("%s : ", test[k]);
printf("%d digits\n", count_digits(test[k]));
}
return 0;
}
int count_digits(char* text)
{
// TODO: Insert your code here...
// TODO: Temporary stub return...
return 0;
}
Write the source code to count the number of digits in the C-String passed into the
count_digits function.
Follow good programming standards for whitespace, naming and commenting.
Test your program to ensure the implementation is robust and the program correctly outputs the
number of digits in each C-String.
Step by step
Solved in 3 steps with 2 images