0

Write a C program that prompts the user to enter integers (positive or negative, not including 0) from the keyboard. Your program should stop reading the numbers from the keyboard when the value 0 is entered and print the range (the difference between the maximum and the minimum) of the numbers. Note that 0 is not part of the data. Comment your program liberally.

this is what i have so far

#include <stdio.h>
#include <math.h>
#include <conio.h>

int main()

int max=0, min=0, NH, r;
    printf("Imput your test scores \n");
    printf("Enter 0 as a test score to calculate your range \n");
    scanf("%i",&NH);

    do{
        if (NH>max)
            max=NH;
        else
        {
            if (NH<min)
                min=NH;
            else
            {   printf("Enter another test score\n");}      
        }
    }while (NH!=0);
    r=max-min;
    printf("%i", r);
    getch();


    return 0;
        }




    getting an error message reading:
    error C1075 end of the file found be4 the left brace


    aka im missing a curly brace and cant igure out where.... also will this program work correctly???
2
Contributors
1
Reply
18
Views
4 Years
Discussion Span
Last Post by zeroliken
1

your missing the starting curly brace of the main function

also will this program work correctly???

it "should" work but it doesn't match your requirements
at your loop you didn't prompt the user for input again

Edited by zeroliken

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.