@pacman line 27 is an error you can't assign to a literal char' ' = 0;
line 28 too while (std::cin >> '|') standard input cant write
to a literal. replace that with an identifier.
edit: you dont need them remove them it would compile fine.
well are you serious? :D, i thought you wrote it ?
i think what the program does is simply request values(double) from the user from std input
with a while loop and then finds the highest, lowest and the sum from the entries, and exists if the user enters a non integral type or a '|' , display result, that's all.
#include <stdint.h>
#include <limits>
#include<iostream>
int main()
{
std::cout << "Please enter some floating-point values | to quit";
double num, sum, min, max;
sum = 0;
min = std::numeric_limits<int>::max();
max = std::numeric_limits<int>::min();
while (std::cin >> num){
sum += num;
if (num > max)
max = num;
if (num < min)
min = num;
}
///char ' ' = 0; this is illegal , plus you dont need it.
///while (std::cin >> '|') this is illegal ,
std::cout << "Sum = " << sum
<< "\nMax = " << max
<< "\nMin = " << min << std::endl;
return 0;
}
/// you must enter arthmetic types that can be converted to double
to prevent exit when you enter a character you might consider either using while(std::cin) or while(!std::cin.fail()) or while(std::cin.good() to check the state of you stream
and then add std::cin>>num above sum += num;
here
1 2 3 4 5 6 7 8
while (std::cin >> num)
{
sum += num;
if (num > max)
max = num;
if (num < min)
min = num;
}
#include <stdint.h>
#include <limits>
#include<iostream>
int main()
{
std::cout << "Please enter some floating-point values | to quit ";
double num, sum, min, max;
sum = 0;
min = std::numeric_limits<double>::max();
max = std::numeric_limits<double>::min();
while (std::cin >> num){
sum += num;
if (num > max)
max = num;
if (num < min)
min = num;
}
if (!std::cin) { // we get here only if an input operation failed
if (std::cin.fail()) { // stream encountered something unexpected
std::cin.clear(); // make ready for more input
std::cout << "Sum = " << sum
<< "\nMax = " << max
<< "\nMin = " << min << std::endl;
return 0;
}
}
}