#include <iostream>
#include <cstring>
usingnamespace std;
int main()
{
constint LENGTH = 100; //length of string
char bob[LENGTH]; //string declaration
int total=0, index; // initialize to zero
int max = 0; //initialize max to random element
int min =0; // initialize min to random element
cout << "Enter a series of numbers in a row: "; // prompts user
cin >> bob; // enter digits
for (index=0; index < strlen( bob ); index++) // read through string
{
total += bob[index] - '0'; // add them together
}
cout << "The total is " << total << endl;
for (index=0; index < LENGTH; index++)// read through string
{
if (bob[index] > max)// find max
{
max = bob[index];
}
elseif (bob[index] < min) // find min
{
min = bob[index];
}
}
cout << "The max is: " << max << endl << "The min is: " << min << endl ;
return 0;
}
cout << "Enter a series of numbers in a row: "; // prompts user
cin >> bob; // enter digits
this will only add 1 number to the first index,
cout << "Enter a series of numbers in a row: "; // prompts user
for (int i = 0; i < LENGTH; i ++)
{
cin >> bob[i];
}
since you are using char, if you do any type of operations to it, it will perform the operations to the ASCII code equivalent of the char, not what the value of the char represents, does this make sense?
ask the user before to enter how many values they would wish
cin >> size
and make a for loop with i < size;
or you can make a while loop, where;
bool found = false;
while (!found)
{
cin >> bob;
cout <<"do you want to continue? (y/n);
cin >> choice;
if (choice == y || choice == Y_
found = true;