1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
LiRa [457]
4 years ago
13

(1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted

: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string: Jill, Allen (2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts) Ex: Enter input string: Jill Allen Error: No comma in string Enter input string: Jill, Allen (3) Extract the two words from the input string and remove any spaces. Store the strings in two separate variables and output the strings. (2 pts) Ex: Enter input string: Jill, Allen First word: Jill Second word: Allen (4) Using a loop, extend the program to handle multiple lines of input. Continue until the user enters q to quit. (2 pts) Ex: Enter input string: Jill, Allen First word: Jill Second word: Allen Enter input string: Golden , Monkey First word: Golden Second word: Monkey Enter input string: Washington,DC First word: Washington Second word: DC Enter input string: q

Computers and Technology
1 answer:
denis-greek [22]4 years ago
4 0

Answer:

Check the explanation

Explanation:

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#define MAX_LIMIT 50

int checkComma(char *input)

{

int flag = 0;

for(int i = 0; i < strlen(input); i++)

{

if(input[i] == ',')

{

flag = 1;

break;

}

}

return flag;

}

int main(void)

{

char input[MAX_LIMIT];

char *words[2];

char delim[] = ", ";

printf("\n");

do

{

printf("Enter input string: ");

fgets(input, MAX_LIMIT, stdin);

size_t ln = strlen(input) - 1;

if (*input && input[ln] == '\n')

input[ln] = '\0';

if(strcmp(input, "q") == 0)

{

printf("Thank you...Exiting\n\n");

exit(1);

}

else

{

if(checkComma(input) == 0)

{

printf("No comma in string.\n\n");

}

else

{

char *ptr = strtok(input, delim);

int count = 0;

while(ptr != NULL)

{

words[count++] = ptr;

ptr = strtok(NULL, delim);

}

printf("First word: %s\n", words[0]);

printf("Second word: %s\n\n", words[1]);

}

}

}while(strcmp(input, "q") != 0);

return 0;

}

Kindly check the attached image below for the output.

You might be interested in
Which of the following correctly defines a procedure in computer programming? Choose all the apply.
Kazeer [188]

Explanation:

A code block programmers can reuse multiple times

3 0
4 years ago
Read 2 more answers
How to add a bill using the reciept capture?
HACTEHA [7]

Answer: add up all the numbers and then add the tax and then 30% of the total for the tax

Explanation:

like 3+6+8+10=26

26 30%=whatever that is and then add it all up againg and thta is your answer.

5 0
3 years ago
Discuss five domains of Instructional technology​
Effectus [21]

Answer:

Design, Development, Utilization, Management, and Evaluation.

7 0
3 years ago
Which subunit of a heterodimeric cdk is the regulatory subunit?
Lemur [1.5K]
The answer is cyclin subunit
8 0
3 years ago
A nurse is reviewing the different cloud office applications available. When comparing the iCloud to other cloud office applicat
hoa [83]

Answer:

A nurse should have to consider a

  • web browser to access the app
  • the app is not a downloadable type

Reasons have explained in the explanation.

Explanation:

All apps can find a copy of the phone's web browser in the app drawer. Google Chrome is the name of Google's browser that can use for reviewing the different cloud applications.

A Web application is  stored on the server and over the internet through an interface.

She should have to use these features.

8 0
3 years ago
Other questions:
  • Show the printout of the following code.
    14·1 answer
  • What is the difference between a software package and integrated software
    7·1 answer
  • FREE POINTS JUST ANSWER MY LATEST TWO QUESTIONS PLEASE
    10·2 answers
  • Use BlueJ to write a program that reads a sequence of data for several car objects from an input file. It stores the data in an
    5·1 answer
  • ______________ helps you see how your document will appear on the paper. ​
    10·1 answer
  • In what Career Cluster you get to design, build, and destroy things
    6·1 answer
  • What starts with p and ends with orn
    15·2 answers
  • Need help with Python coding from Zybooks...
    9·1 answer
  • When companies charge different prices for the same product, they're using
    12·1 answer
  • When viewing an e-book section of an assignment in launchpad, you can return to your main course page at any time by clicking th
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!