Question

Write a fragment of code that reads in a header value from the standard input and...

Write a fragment of code that reads in a header value from the standard input and then reads in that many integers (also from standard input) and prints their sum to standard output (for loops, header values, accumulators, basic arithmetic). Declare any variables you use.

part b

Objects of the Calculator class require no additional information when created. Define an object named calc, of type Calculator.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) Code fragment:

  
   int *p;
   cin >> header_value;
   p = new int[headr_value];
   for (int i = 0; i<header_value; i++)
       cin >> p[i];
   int sum = 0;
   for (int i = 0; i<header_value; i++)
       sum = sum + p[i];
   cout << sum;

b) Calculator calc;

Add a comment
Know the answer?
Add Answer to:
Write a fragment of code that reads in a header value from the standard input and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT