Need a favor!!!

This is a discussion on Need a favor!!! within the C++ Programming forums, part of the General Programming Boards category; Can someone take this program and run it in thier complier and let me know it it runs or not. ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    19

    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;
    }

  2. #2
    Me again
    Guest
    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

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    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; 
    }
    zMan

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    19

    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.

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    223
    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...
    zMan

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Brand new to C need favor
    By dontknowc in forum C Programming
    Replies: 5
    Last Post: 09-21-2007, 10:08 AM
  2. RAND() Does it favor the lower number?
    By Queatrix in forum C++ Programming
    Replies: 4
    Last Post: 04-12-2006, 02:38 PM
  3. Asking a favor of anyone with a GeForce 3
    By psychopath in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 07-23-2005, 09:49 PM
  4. Could someone do me a REALLY quick favor
    By DarkViper in forum Windows Programming
    Replies: 1
    Last Post: 08-10-2003, 04:50 AM
  5. Can Someone Do Me A Favor Please?
    By MicroFiend in forum C++ Programming
    Replies: 2
    Last Post: 03-20-2003, 12:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21