Thread: help, it wont run at all.

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    1

    help, it wont run at all.

    I have this program that has no errors (good news), but wont run at all (bad news) and i need it in by 1159 tonite. think anyone can help me. well here it is

    #include <stdio.h>

    float main()

    {

    float numbers[6]={100, 500, 10, 90, 7, -1};
    float maximum_value;
    float minimum_value;
    float sum;
    float average;
    float i;
    float count;

    printf("There are 5 integers in the file. We will be finding the max, min, sum, and ave of all of the integers\n", numbers);
    scanf(&numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5]);
    while(numbers[0]>0);
    {
    scanf("%f", &numbers[0]);
    i=0;
    count=0;
    maximum_value=numbers[0];
    i=maximum_value;
    count=count++;
    sum=maximum_value;
    }
    while(numbers[1]>0);
    if(numbers[1]>numbers[0]);
    {

    scanf("%f", &numbers[1]);
    sum=maximum_value+numbers[1];
    maximum_value=numbers[1];
    i=maximum_value;
    count=count++;
    }
    minimum_value=numbers[1];
    while(numbers[2]>0);
    if(numbers[2]>numbers[1]);
    {
    scanf("%f", &numbers[2]);
    sum=maximum_value+numbers[2];
    maximum_value=numbers[2];
    i=maximum_value;
    count=count++;
    }
    minimum_value=numbers[2];
    while(numbers[3]>0);
    if(numbers[3]>numbers[2]);
    {
    scanf("%f", &numbers[3]);
    sum=maximum_value+numbers[3];
    maximum_value=numbers[3];
    i=maximum_value;
    count=count++;
    }
    minimum_value=numbers[3];
    while(numbers[4]>0);
    if(numbers[4]>numbers[3]);
    {
    scanf("%f", &numbers[4]);
    sum=maximum_value+numbers[4];
    maximum_value=numbers[4];
    i=maximum_value;
    count=count++;
    }
    minimum_value=numbers[4];
    while(numbers[5]>0);
    if(numbers[5]>numbers[4]);
    {
    scanf("%f", &numbers[5]);
    sum=maximum_value+numbers[5];
    maximum_value=numbers[5];
    i=maximum_value;
    count=count++;
    }
    minimum_value=numbers[5];
    average=sum/count;

    printf("The maximum value of the integers is %f.2\n", maximum_value);
    printf("The minimum value of the integers is %f.2\n", minimum_value);
    printf("The sum of the integers is%f.2\n", sum);
    printf("The average of the integers is %f.2", average);
    {
    return 0; /*back to 0*/
    } /*end*/

    }

  2. #2

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Nice - now go read the forum rules then edit your post to include code tags
    Please use [code][/code]Tags

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Oh I decided to be nice:
    I have this program that has no errors
    Oh really:
    g++ -Wall -ansi -pedantic -o bt3 bt3.cpp
    bt3.cpp:5: warning: return type for `main' changed to `int'
    bt3.cpp: In function `int main(...)':
    bt3.cpp:15: warning: too many arguments for format
    bt3.cpp:16: passing `float *' as argument 1 of `scanf(const char *, ...)'
    make: *** [bt3] Error 1
    You should treat every warning as an error until you exactly which warnings you can ignore.

  5. #5
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    I'd say that a program that compiles but doesn't run has some serious errors

  6. #6
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    A big problem is in your improper use of while loops:

    Code:
    while(numbers[0]>0);
    ...
    while(numbers[1]>0);
    ...
    while(numbers[2]>0);
    ...
    while(numbers[3]>0);
    ...
    while(numbers[4]>0);
    ...
    while(numbers[5]>0);
    Each of these are infinitely executing loops that do nothing for values in the array greater than 0 because of the poor placement of the semicolon.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  7. #7
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>float main()
    At least it's not void...

    >>scanf(&numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5]);
    You better look up the scanf() function again.

    >>printf("There are 5 integers in the file. We will be finding the max, min, sum, and ave of all of the integers\n", numbers);

    You better look up the printf() function again.

    >>while(numbers[0]>0);
    What hk_mp5kpdw said.

    To name a few
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Re-doing a C program to run in Win2000 or XP
    By fifi in forum C Programming
    Replies: 5
    Last Post: 08-17-2007, 05:32 PM
  2. how to run an exe command in c++ and get back the results?
    By mitilkhatoon in forum C++ Programming
    Replies: 5
    Last Post: 09-21-2006, 06:00 PM
  3. calculating the mode
    By bigggame in forum C Programming
    Replies: 10
    Last Post: 06-13-2006, 03:04 AM
  4. How I can Run exe file in C++
    By palang in forum C++ Programming
    Replies: 2
    Last Post: 05-10-2006, 11:55 AM
  5. Replies: 2
    Last Post: 10-29-2002, 04:56 PM