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
notka56 [123]
3 years ago
7

Write a function template called total. The function will keep a running total of values entered by the user, then return the to

tal. The function will accept one int argument that is the number of values the function is to read. Test the template in a simple program that would prompt the user to enter the number of values to read and then read these values from stdin and output the total. The program will repeat this procedure first for integers, then for doubles.
Computers and Technology
1 answer:
pshichka [43]3 years ago
5 0

Answer:

The template is given in C++

Explanation:

#include <iostream>

using namespace std;

//Template function that returns total of all values entered by user

template <class T>

T total (int n)

{

   int i;

   //Initializing variables

   T sum = 0, value;

   //Prompting user

   cout << "\n Enter " << n << " values: \t ";

   //Iterate till user enters n values

   for(i=1; i<=n; i++)

   {

       //Reading a value

       cin >> value;

       //Accumulating sum

       sum = sum + value;

   }

   //Return sum

   return sum;

}

//Main function

int main()

{

   int n;

   //Reading n value

   cout << "\n Enter number of values to process: ";

   cin >> n;

   //Calling function for integers and printing result

   cout << "\n\n Total : " << total<int>(n);

   cout << "\n\n";

   //Function call for doubles and printing results

   cout << "\n\n Total : " << total<double>(n);

   cout << "\n\n";

   return 0;

}

You might be interested in
Which domain suffixes do businesses that sell products and services commonly use?
sineoko [7]
I’m having a hard time understanding your question
8 0
4 years ago
Read 2 more answers
What term describes an instance of a program being executed?
ale4655 [162]
The term would process. A process is an instance of a program being executed.
6 0
3 years ago
What is the difference between special purpose software and customized software​
Leviafan [203]
The choice of a specific software product model depends on your business specs. General-purpose solutions cover a set of the most common functions. The tailor-made one allows you to stand out for the individual approach for business processes and tasks.Jul 27, 2020
8 0
3 years ago
Read 2 more answers
While adding information to the employee information database, Neil's computer crashed, and the entire database was erased. Whic
Varvara68 [4.7K]

Answer:

logic bombs

Explanation:

logic bombs -

It consists of certain coding , which is put into the software and will perform certain malicious function at the very correct time, is known as logic bomb ,

they are also known as time bomb.

It is a time of virus , but gets activated as soon as all conditions are met , which is coded in to the software.

Hence , from the given scenario of the question,

The correct term is logic bomb.

6 0
3 years ago
When you call a ____________ method, it executes statements it contains and then returns a value back to the program statement t
Maksim231197 [3]

Answer:

The answer is a VOID method.

Explanation:

A void method is one that simply performs a task and then terminates.

4 0
4 years ago
Read 2 more answers
Other questions:
  • Windows uses a memory-management technique known as ________ to monitor which applications you frequently use and preloads them
    15·1 answer
  • TCP has a 32-bit sequence number field and 16-bit advertised window field. Assume that RTT is 512 (2 9 ) ms, transmission speed
    6·1 answer
  • Your colleagues are discussing the operation of a device in which packets are routed between VLANs on the device rather than hav
    7·1 answer
  • Refer to the exhibit. If a hacker on the outside network sends an IP packet with source address 172.30.1.50, destination address
    11·1 answer
  • Using for loop . Input an integer and identify whether it's EVEN OR ODD ( without using modulo operator )
    9·1 answer
  • Excel allows you to rotate text in a cell counterclockwise by entering a number between -1 degrees and -90 degrees. True or fals
    14·1 answer
  • What is the speed of Android operating system?
    6·1 answer
  • Any song recommendations, pls dont say 6ix9ine or lil pump
    5·2 answers
  • ___1. my1st JavaProgram<br> A. valid <br> B. invalid
    13·1 answer
  • What are the dominant InfoSec-related credentials used to document knowledge and/or experience?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!