Sign in to follow this  
Nanook

error while compiling..

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this