>>number = 0 = num_count = 0 = total = 0;
for one thing, this line would be better off as:
number = num_count = total = 0;
makes sense to you why, I hope.
Code:
while ( number < 1 ) do
{
printf("\nEnter number of repititions > ");
scanf("%d" ,&number);
if( number < 1 ) then
printf("\nNumber must be > 1\n");
}
You obviously haven't read up on how to loop correctly, try:
Code:
while ( number < 1 )
{
printf("\nEnter number of repititions > ");
scanf("%d" ,&number);
if( number < 1 )
{
printf("\nNumber must be > 1\n");
}
for a while loop, and
Code:
do
{
printf("\nEnter number of repititions > ");
scanf("%d" ,&number);
if( number < 1 )
{
printf("\nNumber must be > 1\n");
}
while ( number < 1 );
for a do-while loop.
also, there's no "then" in C, so get rid of that, and replace it with a bracket {
Code:
for( num_count = 0, num_count < number; num_count++ )
change that to
for( num_count = 0; num_count < number; num_count++ )
because you had a comma there instead of a semicolon.
Code:
switch ( value )
{
case value > hi : hi = value;
break;
case value < low: low = value;
break;
case default: break;
}
change that to two if statements, because you can't evaluate expressions in a switch-case.
Code:
total:= total + value;
this isn't Pascal! you meant total= total + value; right?
also, on your very last line add a } to close off the main function
Warning: don't look at this if you don't want to see the fixed version of your program - I took the liberty of doing so as I was fixing it
Code:
#include <stdio.h>
int hi, low, number , num_count, value, average, total;
void main()
{
/* set hi to owest integer value and low to highest
integer so that they will change */
hi = -32768;
low = 32767;
number = num_count = total = 0;
/* test to ensure number of inputs is positive */
while ( number < 1 )
{
printf("\nEnter number of repititions > ");
scanf("%d" ,&number);
if( number < 1 )
{
printf("\nNumber must be > 1\n");
}
}
/* loop for input of numbers */
for( num_count = 0;num_count <number; num_count++ )
{
printf("Enter number #%d > ", num_count+1);
scanf ("%d" , &value );
/* test for highest and lowest values */
if(value > hi)
hi = value;
else if(value < low)
low = value;
total= total + value;
}
/* Calculate and display average */
average = total / number;
printf("\nAverage of %d numbers is %d", number, average);
/* display highest and lowest values */
printf("\nHighest Value is %d, Lowest is %d\n" , hi, low);
}