-
Need a favor!!!
Can someone take this program and run it in thier complier and let me know it it runs or not. I am beginning to think my comipler is messed up (Quincy 99). I get this error (gcc.exe: cannot specify -o with -c or -S and multiple compilations) when I try to complie or execute it.
Thank you if you can help.
#include <iostream.h>
int main()
{
const int MAX = 50;
int count = 0;
int index = 0;
float numbers_array[MAX];
char ch = 'Y';
int max;
int min;
int i = 0;
do
{ while(ch == 'Y' || ch == 'y')
{
cout << "Please enter a number: ";
cin >> numbers_array[index];
index++;
count++;
cout << "Do you want to enter another number? (Y/N) ";
cin >> ch;
}
min = numbers_array[0];
max = numbers_array[0];
while (i < MAX)
{
if (number_array[i] < min)
{
min = number_array[i];
}
else (number_array[i] > max)
{
max = number_array[i];
}
i++;
}
cout << "You entered a total of" << count;
cout << "numbers." <<endl;
cout << "The largest number you entered was " << max << endl;
cout << "The smallest number you entered was " << min << endl;
cout << "Do you want to re run this program? (Y/N);
cin >> ch;
}
while (ch == 'Y' || ch == 'y')
return 0;
}
-
I get these errors when trying to compile:
c:\mydocu~1\untitl~1.cpp:46: unterminated string or character constant
c:\mydocu~1\untitl~1.cpp:46: possible real start of unterminated constant
-
compiler errors
Here is the edited code.... there was a few errors. I fixed them an it ran. Check out the comments....
Code:
int main()
{
const int MAX = 50;
int count = 0;
int index = 0;
float numbers_array[MAX];
char ch = 'Y';
int max;
int min;
int i = 0;
do
{
while(ch == 'Y' || ch == 'y')
{
cout << "Please enter a number: ";
cin >> numbers_array[index];
index++;
count++;
cout << "Do you want to enter another number?(Y/N) ";
cin >> ch;
}
min = numbers_array[0];
max = numbers_array[0];
while (i < MAX)
{
//numbers_array was number_array
if (numbers_array[i] < min)
{
min = numbers_array[i];
}
else if/*missing if*/(numbers_array[i] > max)
{
max = numbers_array[i];
}
i++;
}
cout << "You entered a total of" << count;
cout << "numbers." <<endl;
cout << "The largest number you entered was " << max << endl;
cout << "The smallest number you entered was " << min << endl;
cout << "Do you want to re run this program?(Y/N)"/*missing " */;
cin >> ch;
}while (ch == 'Y' || ch == 'y'); /*missing ; */
return 0;
}
-
What compiler do you use
What complier are You using? I tried the code you gave again and still came up with the same error.
-
I am using visual c++ 6.0....
Are you compiling from the command line? I am not very familiar with compiling from the command line but I do know that there are several steps to compile...