answer.
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
masha68 [24]
1 year ago
15

Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer

s that follow Then, get the last value from the input, which indicates a threshold. Output all integers less than or equal to that last threshold value. Assume that the list will always contain less than 20 integers. Ex: If the input is 5 50 60 140 200 75 100 the output is 50 60 75 The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75. For coding simplicity, follow every output value by a space, including the last one. Such functionality is common on sites like Amazon, where a user can filter results.
Computers and Technology
1 answer:
Naya [18.7K]1 year ago
4 0

Answer:

The program to this question as follows:

Program:

#include<iostream> //include header file.

using namespace std; //using name space.

int main() //main function.

{

int n,i,key; //define variable.

int a[n]; //define array

cout<<"Enter size of array :"; //message.

cin>>n; //input number from user.

cout<<"Enter array elements :"; //message

for(i = 0;i<n;i++) //loop

{

cin>>a[i]; //input array elements

}

cout<<"Enter a number:"; //message

cin>>key; //input number.

for(i = 0;i<n;i++) //loop

{

if(a[i]<=key) //if block

{

cout<<a[i]<<"\n "; //print array elements

}

}

return 0;

}

Output:

Enter size of array :7

Enter array elements :5

50

50

75

100

200

140

Enter a number:100

5

50

50

75

100

Explanation:

The description of the above program as follows:

  • In this program first, we include a header file and define the main method in method we define variables and array that are "n, i, key and a[]". In this function, all variable data type is "integer".
  • The variable n is used for the size of array and variable i use in the loop and the key variable is used for comparing array elements. Then we use an array that is "a[]" in the array, we use the for loop to insert elements form user input.  
  • Then we define a loop that uses a conditional statement in if block we check that array elements is less than and equal to a key variable. If this value is true so, we will print the remaining elements.  

You might be interested in
1. Do you consider Facebook, MySpace, and LinkedIn forms of disruptive or sustaining technology? Why?
Mrrafil [7]
It mainly just depends on if you "misuse" them.
8 0
2 years ago
A user complains that his computer automatically reboots after a short period of time. Which of the following computer component
satela [25.4K]

Answer:

C

Explanation:

A faulty motherboard causes a computer to reboot after a short period of time.

The motherboard is a printed circuit board, It transmits power and allows for effective communication to and between the RAM, CPU and all other computer external components. Motherboard is essential for the coordination of all the activities in the computer.

A faulty motherboard could be as a result of a leaking capacitor in it, which is caused by a bad power source.

If that occurs there is need for replacement of the Motherboard to ensure the smooth running of the computer.

8 0
2 years ago
Read 2 more answers
Assign decoded_tweet with user_tweet, replacing any occurrence of 'TTYL' with 'talk to you later'. Sample output with input: 'Go
nekit [7.7K]

Answer:

I am going to use the Python programming language to answer this. The source code is given below:

print("Enter your tweet here")

user_tweet = input()

decoded_tweet = user_tweet.replace('TTYL', 'talk to you later')

print("This is the decoded tweet: ")

print(decoded_tweet)

Explanation:

In the program the replace() module was used to replace 'TTYL' with 'talk to you later.'

Attached is the screenshot of the output.

8 0
2 years ago
Read 2 more answers
Write the definition of a class Telephone. The class has no constructors, one instance variable of type String called number, an
balu736 [363]

Answer:

The definition of a class Telephone is given as  

public class Telephone // class telephone

{

String number; // variable  number of type string

static int quantity = 250; // variable  quantity  of type int

static double total = 1565.92;  // variable  total  of type double

}

Explanation:

Following is the description of Statement

  • Create a class "Telephone" by using the keyword class.In that class we declared data member .
  • We declared a variable "number" of type "string" which has no constructor.
  • We declared a variable  "quantity" of type "int" which is a static type variable. The static type variable retains the value during the program execution.
  • We declared a variable  "total" of type "double" which is a static type variable. The static type variable retain the value during the program execution .
5 0
2 years ago
A file concordance tracks the unique words in a file and their frequencies. Write a program that displays a concordance for a fi
victus00 [196]

Answer:

I am writing a Python program.

def concordance(filename):  # function that takes a file name as parameter and returns the concordance for that file

   file = open(filename,"r")  #opens file in read mode

   unique={}  #creates and empty list

   for word in file.read().split():  #loops through every word in the file

       if word in unique:  # if words is already present in the list

           unique[word] += 1  #add 1 to the count of the existing word

       else:    #if word is not present in the list

           unique[word] = 1 #add the word to the list and add 1 to the count of word

           file.close();  # close the file

   for x in sorted(unique):  #sort the list and displays words with frequencies

       print(x, unique[x]);  #prints the unique words and their frequencies in alphabetical order

#prompts user to enter the name of the file

file_name=input('Enter the input file name: ')

concordance(file_name)  #calls concordance method by passing file name to it

Explanation:

The program has a function concordance that takes a text file name as parameter and returns a list of unique words and their frequencies.

The program first uses open() method to open the file in read mode. Here "r" represents the mode. Then creates an empty list named unique. Then the for loop iterates through each word in the file. Here the method read() is used to read the contents of file and split() is used to return these contents as a list of strings. The if condition inside the loop body checks each word if it is already present in the list unique. If the word is present then it adds 1 to the count of that word and if the word is not already present then it adds that unique word to the list and assign 1 as a count to that word. close() method then closes the file. The second for loop for x in sorted(unique):  is used to display the list of unique words with their frequencies. sorted() method is used to sort the list and then the loop iterates through each word in the list, through x, which acts like an index variable, and the loop displays each word along with its frequency.

6 0
1 year ago
Other questions:
  • U.S. industries like steel, computers, and energy need to be protected from foreign competition to ensure which of the following
    6·2 answers
  • PLEASE HELP!! WILL GIVE BRAINLIEST!!
    15·2 answers
  • Prove that any amount of postage greater than or equal to 64 cents can be obtained using only 5-cent and 17-cent stamps?
    15·1 answer
  • Writing a program in a language such as c or java is known as _____ the program.
    10·1 answer
  • Leena needs to manually update the TOC and would prefer not to change the styles in the document.
    9·2 answers
  • Why is the following statement true - ideally, your information is abbreviated
    10·2 answers
  • Which two factors most influenced the growth of the Internet during the 1970s?
    7·2 answers
  • A function defined beginning with void SetNegativesToZeros(int userValues[], ... should modify userValues such that any negative
    12·1 answer
  • Write a flowchart and C code for a program that does the following: Within main(), it asks for the user's annual income. Within
    12·1 answer
  • If Maya wants to access a view that would control multiple slides within a presentation, which view should she utilize? Master v
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!