• Advertisement
Sign in to follow this  

error while compiling..

This topic is 3669 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

int main()
	float num1, num2, arithMean, geoMean, harmMean;

	printf("Pleas input first number: ");
	scanf("%lf%*c", &num1);

	printf("Pleas input second number: ");
	scanf("%lf%*c", &num2);

	arithMean = (num1 + num2)/2;
	geoMean = sqrt(num1 * num2);
	harmMean = 2/((1/num1)+(1/num2));

	printf("The arithmetric mean is, %lf" , arithMean);
	printf("The geometric mean is, %lf" , geoMean);
	printf("The harmonic mean is, %lf" , harmMean);

	if ((arithMean > geoMean) && (arithMean > harmMean))
		printf("The arithmetic Mean is the largest");
	else-if (geoMean > harmMean)
		printf("The geometric mean is the largest");
		printf("The harmonic mean is the largest");

trying to compile this I get the following error.. and I cant understand why.. H:\ict102\week3>bcc32 mean.c Borland C++ 5.2 for Win32 Copyright (c) 1993, 1997 Borland International mean.c: Error mean.c 24: Expression syntax in function main Error mean.c 26: Misplaced else in function main *** 2 errors in Compile ***

Share this post

Link to post
Share on other sites
You were almost there, just take out the dash in else-if and put whitespace in its place. I think that should cover it without compiling it myself.

Share this post

Link to post
Share on other sites
Original post by Hodgman
Why is there a hyphen in "else-if" ?
[edit] Too slow ;) ^^^

Cause Im a noob :D cheers.. :)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement