Have seen this error posted but no solutions that work for me.Here is what I have and it goes thru the debug but doesn't compile without this error message usually with the error marker around line 20. The call stack says !main() Line 20 + 0xfbytes, and That's greek to me. Thanks
#include<iostream>
usingnamespace std;
int main ()
{
constint NUM_LETTERS = 11;
char letters [NUM_LETTERS];
cout << "Please enter up to 10 letters." << endl;
cin >> letters [NUM_LETTERS];
for (int i = 0; i < NUM_LETTERS; i++)
{
if((letters[i]>=97) &&(letters[i]<=122)) // checking if character is lowercase.
letters[i] - 32; // convert to uppercase.
cout << "This is the changed letters. " << letters[i] << endl;
}
return 0;
}
Thanks for the reply.
I would use the code you suggest however we haven't been shown the easy way to do stuff yet. I suppose it's to develop our troubleshooting skills as well as teach an alternate coding method. It sure does get frustrating at times.
I made the changes and added a pause and it works, kind of. It shows blank statements if you only put in a few letters filled with garbage. How would I add a statement to let the user know they entered more than 10 letters or unusable data (numbers or special characters) to keep the program from showing a stack error like it does? or is it feasible? better a dialogue box than an error message is how I'm thinking (doesn't mean I'm correct tho).
#include<iostream>
usingnamespace std;
int main ()
{
constint NUM_LETTERS = 10;
char letters [NUM_LETTERS];
cout << "Please enter up to 10 letters." << endl;
cin >> letters;
for (int i = 0; i < NUM_LETTERS; i++)
{
if((letters[i]>=97) &&(letters[i]<=122)) // checking if character is lowercase.
letters[i] -= 32; // convert to uppercase.
cout << "These are the changed letters. " << letters[i] << endl;
if (letters[i] < 97 || > 122)
}
system ("pause");
return 0;
}
/*
Kelly Handley
Chap7_1
October 20, 2010
*/
/*
This program will ask the user to enter 10 numbers then display the largest and
smallest.
*/
#include<iostream>
#include<iomanip>
usingnamespace std;
constint input = 10;
double numbers[input];
double Max, Min;
int main()
{
//ask user for input
for (int i = 0; i < input; i++)
{
cout << "Enter ten numbers " << (i + 1) << endl;
cin >> numbers[i];
}
//calculate maximum value
Max = numbers[0];
for (int i= 0; i< input; i++)
{
if (numbers[i] > Max)
{
Max = numbers[i];
}
}
//calculate minimum value
Min = numbers[0];
for (int i= 0; i< input; i++)
{
if (numbers[i] < Min)
{
Min = numbers[i];
}
}
//Display results
cout << "The largest number is: \t\t" << Max << endl;
cout << "The smallest number is: \t" << Min << endl;
//pause program to see results
system("pause");
return 0;
}