View Single Post
  #7  
Old 10-31-2006, 10:00 AM
RedJoker RedJoker is offline
Senior Member
 
Join Date: Aug 2006
Location: High on Life
Posts: 2,353
Default Re: C Programming Noob - Need Help Plz.

Thanks to everyone for all your help.

The following code is just adapting Lurker's original code. I know this is probably messy and illogical but I'll post it anyway and we can go from there.



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

void main()

float n;
double product = 1;
double sum = 0;
double geommean = 1;
double arithmean = 0;
double a;

printf("Please enter a float n: ");
scanf("%d", &n);
printf("\n");

for (int i = 1; i<= n; i++)
{
printf("Enter double %d:", i)
scanf("%f", &a);
printf("/n");
sum = sum + a;
product = product * a;
if(i == 0)break;
arithmean = sum/n;
geommean = product^(1/n);
}

printf("arithmetic mean is: %d\n", arithmean)
printf("geometric mean is: %d\n", geommean)


I know this is probably very basic stuff but it's the first time I've done any type of programming. At the moment it's like trying to understand japanese. I probably just need more exposure to it.

If you could point out the mistakes in the code that would be great (plz be gentle). Thanks again.
Reply With Quote