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]
3 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]3 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
What is the difference between a workbook and a worksheet?
Snowcat [4.5K]
An Excel worksheet is a single spreadsheet that contains cells organized by rows and columns. A worksheet begins with row number one and column A. Each cell can contain a number, text or formula. A cell can also reference another cell in the same worksheet, the same workbook or a different workbook.
7 0
3 years ago
Read 2 more answers
The city government of Los Angeles recently upgraded its information technology infrastructure​ and, for the first​ time, implem
Maru [420]

Answer:

The correct answer to the following question will be Option A (Open source software).

Explanation:

It's a type of software which is open to all we can download that software by the free of cost. Wamp, Apache server is one of the example of the open source software.

Any software accessible for alteration which is circulated because of its source code is known as Open source software. Open source permissions influence the way technology is used, researched, updated, and circulated by individuals. In fact, it give permission to code users for using this software for whatever use might desire.

Which ensures it includes a developer authorization to modify the script in any manner they want to:

  • Developers will patch glitches.
  • Change features.
  • Modify the app to suit their needs.

No other software available for the alteration is available in the option. So, the proper answer is Option A.

8 0
3 years ago
Which of the following methods is the easiest way to set up a VPN client on a computer for a user who is not technical?
Pie

Answer:

Option D.

Use CMAK to create an executable to install.

Explanation:

The CMAK is the Connection Manager Administration Kit it is a feature in Microsoft Windows that allows users to customize the remote connection experience for users on their network.

The CMAK can be simply used by the technical expert to remotely operate the client computer, and customize the VPN himself without the non-technical user having to do anything. This can be done for computers only on a network however.

3 0
3 years ago
Different between internet and email​
pentagon [3]

Answer:

The internet allows you to connect with people and information around the world. The internet is more broad and could include searching things up or message-based websites. Emails is more specific, with it being when you send someone a message (called an email) on a mail website (that allows you to get messages from other people, websites, etc.)

Explanation:

In my answer.

5 0
3 years ago
NumA=2<br> for count range (5,8)<br> numA=numA+count <br> print(numA)
love history [14]

Answer:

for count in range (5,8): numA=numA+count print(numA)

Explanation:

7 0
3 years ago
Other questions:
  • There are N bulbs numbered from 1 to N, arranged in a row. The first bulb is plugged into the power socket and each successive b
    6·1 answer
  • Tommy has hired a marketing company to create a billboard advertisement
    11·2 answers
  • The ____ dialog box in windows vista appears each time a user attempts to perform an action that can be done only with administr
    12·1 answer
  • In a transaction-processing system (TPS), if the TPS database can be queried and updated while the transaction is taking place,
    12·1 answer
  • Given the security levels TOP SECRET, SECRET, CONFIDENTIAL, and UNCLASSIFIED (ordered from highest to lowest), and the categorie
    13·1 answer
  • What are some hazards of being an astronomer??
    6·1 answer
  • ____ testing is a straightforward testing technique that looks for vulnerabilities in a program or protocol by feeding random in
    6·1 answer
  • Write a program that creates an integer array with 40 elements in it. Use a for loop to assign values to each element of the arr
    5·1 answer
  • Reports produced by the United Nations are considered
    11·2 answers
  • a 2x4 line decoder with enable is implemented using nand gate only. how many nand gate is needed to construct this line decoder?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!