Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Online GDB Show where you put the tree test cases in the code to get the outputs! Use the code below! Write a C

Using Online GDB
Show where you put the tree test cases in the code to get the outputs!
Use the code below!
Write a C program myprog that can accept an arbitrary number of command line arguments, e.g.
myprog Hello, world!
You are not allowed to use any standard string manipulation functions from .
myprog must print each argument starting with the first character on the first line, two characters on the second line, etc. myprog must exclude all characters other than a through z and A through Z. For the parameters specified above, myprog must produce the following output:
H
He
Hel
Hell
Hello
W
Wo
Wor
Worl
World
Use three test cases to verify the correctness of your code as follows:
myprog
myprog Have a nice day!
myprog paraskevidekatriaphobia = Friday 13.
#include
// Step 2: Function to check if a character is an alphabet (A-Z or a-z)
int is_alpha(char c){
return (c >='A' && c ='Z')||(c >='a' && c ='z');
}
// Step 3: Function to print filtered arguments
void print_filtered_arguments(int argc, char *argv[]){
// Iterate through each argument
for (int i =1; i argc; i++){
int len =0;
// Count the number of valid characters in the current argument
for (int j =0; argv[i][j]!='\0'; j++){
if (is_alpha(argv[i][j])){
len++;
}
}
// Print the filtered argument line by line
for (int k =1; k = len; k++){
int count =0;
for (int j =0; argv[i][j]!='\0' && count k; j++){
if (is_alpha(argv[i][j])){
printf("%c", argv[i][j]);
count++;
}
}
printf("
");
}
}
}
// Step 4: Main function
int main(int argc, char *argv[]){
// Call the function to print filtered arguments
print_filtered_arguments(argc, argv);
return 0;
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

Describe key employee expectations.

Answered: 1 week ago

Question

Describe current business topics and their impact on HRM.

Answered: 1 week ago

Question

Define human resources management (HRM).

Answered: 1 week ago