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
Lera25 [3.4K]
3 years ago
5

Write a program that gets a list of integers from a user. First, the user should be asked to enter the number of integers to be

stored in a list. Then your program should ask for these integers and store them in the list. Finally, the program should ask the user to enter a sentinel value that will be used to search through the integers in the list which are greater than the sentinel value. For example: If the input is: 7 50 60 140 200 75 100 172 70 the output is: 140 200 75 100 172 The 7 indicates that there are seven integers in the list, namely 50 60 140 200 75 100 172. The 70 indicates that the program should output all integers greater than 70, so the program outputs 140 200 75 100 172. You should use methods in addition to the main method. getListValues to get and store the values from the user printListValuesGreaterThanSentinal to print the values found to be greater than the sentinel value.
Computers and Technology
1 answer:
Leviafan [203]3 years ago
5 0

Answer:

#include <iostream>

using namespace std;

void insert(int *arr, int num);

int n;

void returnGT(int arr[]);

int main(){

   cout<< "Enter the number of integers: "<<endl;

   cin>>n;

   int num[n];

   insert(num, n);

   returnGT(num);

}

void insert(int *arr, int num){

   for (int i = 0; i < num; i++){

       cout<< "Enter item "<< i + 1 << " : ";

       cin>> arr[i];

   }

}

void returnGT(int arr[]){

   int sentinel;

   cout<< "Enter sentinel: ";

   cin>> sentinel;

   for (int i = 0; i < n; i++){

       if (arr[i] > sentinel){

           cout<< arr[i] << " ";

       }

   }

}

Explanation:

The C++ source code defines an array of integer values, the program prompts for user input for the array size and the sentinel value to fill the array with input values and output integer values greater than the sentinel.

You might be interested in
including how it can be stored and what types of operations we can perform. For example, we can write a program that squares num
ASHA 777 [7]

Answer:

The solution code is written in Python:

  1. def square(num):
  2.    if type(num).__name__ == 'int':
  3.        sq_num = num * num
  4.        return sq_num  
  5.    else:
  6.        return "Invalid input"
  7. print(square(5))
  8. print(square("Test"))

Explanation:

To ensure only certain type of operation can be applied on a input value, we can check the data type of the input value. For example, we define a function and name it as <em>square</em> which take one input number, <em>num </em>(Line 1).

Before the <em>num</em> can be squared, it goes through a validation mechanism in by setting an if condition (Line 2) to check if the data type of the input number is an integer,<em> int.</em> If so, the<em> num </em>will only be squared otherwise it return an error message (Line 6).

We can test our function by passing value of 5 and "Test" string. We will get program output:

25

Invalid input

6 0
4 years ago
Which issue of computer ethics is concerned about the technological division in the society?​
Molodets [167]

Answer:

There are many legal and ethical issues with computers that can be exploited by bad people to do bad things. Some of those issues include illegal music and video file downloading, spyware, identity theft, phishing, keystroke logging, packet sniffing and cyberbullying

7 0
3 years ago
Read 2 more answers
PLEASE HELP
MakcuM [25]

The answer is D: Click on Final in the Display for Review drop-down menu.

Microsoft Word can keep track of changes made words or sentences of a document. It marks the text added or removed. To turn the track changes option on, you will simply click on the Review tab and click Track Changes. To view the edited document without the Track Changes markup, Click on Final in the Tracking group for Review drop-down menu located opposite the Track Changes button.


4 0
3 years ago
Read 2 more answers
What is the first step to apply the line and page breaks options to groups of paragraphs in a Word document?
bezimeni [28]

Answer:

accessing the Paragraph dialog box

Explanation:

8 0
3 years ago
Read 2 more answers
What are the pros and cons of using the internet in a medical office setting?
Shkiper50 [21]
Pros: are doctors are able to educate themselves in order to diagnose a patient, it's fast and convenient to put in records, medical facilities can transfer information from different locations etc.

Cons: the system can breached, this could leak health and personal information from patients, and the power could go down, delaying the use of signing in patients and etc
5 0
3 years ago
Other questions:
  • What is Software? Write the functions of Software?​
    11·1 answer
  • A search engine that crawls uses
    7·1 answer
  • Which of the following is the best definition of a workplace policy?
    13·2 answers
  • Which of the follow represents a form of disruptive technology? Tend to open new markets and destroy old ones A new way of doing
    11·1 answer
  • To filter a list with the Filter function, on an Excel spreadsheet, you need to perform the following steps: (1) click in any ce
    9·1 answer
  • ____ 59. Suppose that x and y are int variables, ch is a char variable, and the input is: 4 2 A 12 Choose the values of x, y, an
    7·2 answers
  • Explain what is meant by information technology (IT). Explain what is meant by information systems (IS). Why is it important to
    7·1 answer
  • Why must you be careful when handling a hard drive?
    10·1 answer
  • Which tool allows users to share code and also serves as a social networking
    10·1 answer
  • Draw truth table for the following logic circuit:<br><br> (Please I really need help with this)
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!