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
Rus_ich [418]
3 years ago
14

in c Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the li

st. The output of the program is every word in the list that contains the character at least once. Assume at least one word in the list will contain the given character. Assume that the list will always contain less than 20 words. Each word will always contain less than 10 characters and no spaces.
Computers and Technology
1 answer:
Fiesta28 [93]3 years ago
3 0

Answer:

see explaination

Explanation:

//Include required header file.

#include <stdio.h>

//Define the function isWordContainChar() having the

//required parameters.

int isWordContainChar(char* req_word, char search_char)

{

//Declare required variable.

int i;

//Start a for loop to traverse the string given in

//the function parameter.

for(i = 0; req_word[i] != '\0' ; i++)

{

//If the current character in the gievn word is

//matched with the character which needs to be

//found in the word, then return 1.

if(req_word[i] == search_char)

{

return 1;

}

}

//Otherwise, return 0.

return 0;

}

//Start the execution of the main() method.

int main(void)

{

//Declare the required variables.

int num_words, index, word_index;

char str_word[20][10];

char searchCharacter;

//Prompt the user to enter the number of words.

scanf("%d", &num_words);

//Prompt the user to enter the required words using a

//for loop and store them into an array.

for(index = 0; index < num_words; index++)

{

scanf("%s", str_word[index]);

}

//Prompt the user to enter a required character which

//needs to be found in a word.

scanf(" %c", &searchCharacter);

//Traverse the words stored in the array using a for

//loop.

for(index = 0; index < num_words; index++)

{

//Call the function isWordContainChar() with

//required arguments in rach iteration and if the

//value returned by this function is not 0, then

//display the current string in the array.

if(isWordContainChar(str_word[index],

searchCharacter) != 0)

{

printf("%s\n", str_word[index]);

}

}

return 0;

}

You might be interested in
Write a program that completes the following requirements in C program:
m_a_m_a [10]

Answer:

#include<stdio.h>

#include<string.h>

int main() {

int n;

FILE *fp = fopen("salaries.txt", "r");

 

double sumSalaries = 0;

double quarterlySalary1, quarterlySalary2, quarterlySalary3, quarterlySalary4;

while(!feof(fp)) {

 

fscanf(fp, "%lf", &quarterlySalary1);

fscanf(fp, "%lf", &quarterlySalary2);

fscanf(fp, "%lf", &quarterlySalary3);

fscanf(fp, "%lf", &quarterlySalary4);

sumSalaries = sumSalaries + quarterlySalary1+quarterlySalary2+quarterlySalary3+quarterlySalary4;

printf("Salary Sum %lf: \n", sumSalaries);

printf("Income Type: ");

if(sumSalaries > 200000 ){

printf("h");

}

else if(sumSalaries >= 15000 && sumSalaries<=200000){

printf("m");

}

else{

printf("l");

}

printf("\n");

}

 

 

fclose(fp);

return 0;

}

Explanation:

4 0
3 years ago
Please join https://www.blooket.com/play?id=386361<br> blooket
netineya [11]
What is blooket used for..........
7 0
3 years ago
What is a Font? I need help please
aleksklad [387]

Answer:

This is the answer, see which is best suited

4 0
2 years ago
Which term describes a set of concepts and practices that provide detailed descriptions and comprehensive checklists, tasks, and
devlian [24]

Answer: Information Technology Infrastructure Library (ITIL)

Explanation:Information Technology Infrastructure Library (ITIL) is the system that contains the practice and information of the various IT services .It is created for the IT businesses that face the risk, cost-degradation and other hazards.

This library provides the services like risk management, improving IT environment and ethics, making stable customer relationship etc.These practices help the information technology organization to change and grow.

3 0
3 years ago
What does the following program do? student = 1 while student &lt;= 3: total = 0 for score in range(1, 4): score = int(input("En
OLga [1]

Answer:

This program prompts for 3 score inputs and calculates the average score (of 3 Test scores) and repeats the process for 3 different students.

Explanation:

the programming language used is python

This is how the code should naturally look like:

student = 1

while student <= 3:

   total = 0

   for score in range(1, 4):

       score = int(input("Enter test score: "))

       total += score

       average = total/3

       print("Student ", student, "average: ", average)

  student += 1

To explain further i.e line by line

student = 1

This indicates that the scores that the program will prompt you to enter belong to the first student  

while student <= 3:

This is a continous loop that breaks only when the student number exceeds 3 (it lets you know that you're iterating over this program 3 times)

total = 0

this initializes the total score to zero. In python this is how variables are initialized an and assigned a data type especially when they will be used again within the program.

for score in range(1, 4):

      score = int(input("Enter test score: "))

The FOR loop is another control structure within the code. It allows you to Iterate between the range 1 - 4 ( i.e. 1,2,3) and prompts you to enter a test score 3 times.

total += score

for each time you are prompted to add a test score, the score is added to the total.

average = total/3

This line calculates the average by dividing by 3

print("Student ", student, "average: ", average)

This line prints out the student number and average score.

e.g: Student 1, average: 14

student += 1

This adds 1 to the previous students number to iterate to the next student.

Final Note: This code can be used for taking students test scores and calculating their average and can be modified further to check if a student passed of failed.

6 0
3 years ago
Other questions:
  • Your bank offers to lend you $114,400 at an 8.5% annual interest rate to start your new business. The terms require you to amort
    11·1 answer
  • A drivers touches a cars steering wheel on a hot day which term refers to the way heat is transferredd to the drivers hand
    6·2 answers
  • Where does the term for a star network describe? A) a network for Department of Defense scientists to share data about the stars
    13·2 answers
  • Tanya is entering the amount of money she has earned from babysitting onto an Excel spreadsheet, but the AutoComplete feature is
    7·1 answer
  • Which of the following things would you access from the Program &amp; Courses page? Course descriptions Tutorial videos Account
    7·1 answer
  • How to find how much storage is left on pc?
    6·1 answer
  • Write the definition of a function named alternator that receives no parameters and returns true the first time it is invoked, r
    10·1 answer
  • You are installing several servers that will be used as web servers to reach customers over the Internet. Where should you place
    14·1 answer
  • What are the possible consequences of plagiarism?
    15·1 answer
  • What year does futurist ray kurzweil believe ai will meet human intelligence?.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!