(Converting Strings to Floating-Point Numbers) Write a program that inputs four strings that represent floating-point values, converts the strings to double values, sums the values and prints the total of the four values. Use only the C-style string-processing techniques shown in this chapter.

What will be an ideal response?


```
#include
#include
using namespace std;

const int SIZE = 6;

int main()
{
char stringValue[ SIZE ];
int sum = 0;

for ( int i = 1; i <= 4; ++i )
{
cout << "Enter an integer string: ";
cin >> stringValue;
sum += atoi( stringValue ); // add converted stringValue to sum
} // end for

cout << "The total of the values is " << sum << endl;
return 0;
} // end main
```
Enter an integer string: 11
Enter an integer string: 22
Enter an integer string: 44
Enter an integer string: 88
The total of the values is 165

Computer Science & Information Technology

You might also like to view...

To identify the table you should give it a(n) __________ name.

A. unique and short B. numeric C. unique and descriptive D. automatically generated

Computer Science & Information Technology

Write down the compiler command that performs the task outlined Question 6 and produces the most optimized code.

What will be an ideal response?

Computer Science & Information Technology

With arbitrary code execution, the ________________ launches ("spawns") a command shell from which instructions can then be issued to the computer.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Which attribute refers to the images folder when specifying the location of an image to display??

A. ?src B. ?loc C. ?pic D. ?fld

Computer Science & Information Technology