Jump to content
  • Advertisement
Sign in to follow this  
Nanook

error while compiling..

This topic is 3935 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");
	else
		printf("The harmonic mean is the largest");

	return(0);
}
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
Advertisement
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
Quote:
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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!