Hi all.. If i knew this website existed it would have saved me hours of useless

noob_dave's Avatar, Join Date: Aug 2007
Newbie Member
Hi all.. If i knew this website existed it would have saved me hours of useless research!!

Hi im David... first year programming.

I was making this code and I keep getting the error

"c:\documents and settings\david\my documents\pp2\real\real\real.cpp(26) : error C2143: syntax error : missing ';' before ')'"

........................................

This is the program I have made, the error is on like 26 but I don't know the reason for the error.

Maby pros like you could help

Code:
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{

	float n1, n2, hn, ln; //Defining variables LINE 10

	printf("Insert first number = ");
	scanf("%f", &n1);

	printf("Insert second number = ");
	scanf("%f", &n2);

	 if ( n1 > n2 ){
      hn = n1;
      ln = n2;  // LINE 20
   } else {        
      hn = n2;
      ln = n1;
        }

	 for (ln < hn; ln++)
	 {
	String formats = "%i  %f  %f\n";
	StdOut.printf(ln, ln * ln, ln * ln * ln);
	 }             //LINE 30

	system("pause");

	return 0;
}

Last edited by shabbir; 9Aug2007 at 17:03.. Reason: Code block
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
The error is
Code:
for (ln < hn; ln++)
and it should be
Code:
for (;ln < hn; ln++)
but I see that you dont have ln initialized and so it should be something like
Code:
for (ln=0;ln < hn; ln++)
0
noob_dave's Avatar, Join Date: Aug 2007
Newbie Member
I tried that before in my original program and the same error appeared, I seriously don't know how it keeps failing...

Lol, I asked my brother who also did programming and he was also puzzled on how it doesn't work.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
You probably need to be working on "Hello World" program because I see you have written even the printf statement incorrect.
0
noob_dave's Avatar, Join Date: Aug 2007
Newbie Member
this is a new sem for me...

last sem we were using the cin, cout approach...

i just converted it into scanf() and printf()...

thx, ill go through my work again and see how it is...
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
Scanf and printf are C functions. One can use them in C++, but writing C as C++ is a fool's mission. Don't bother. Anyone doing woodworking can measure with their forearm, mark with chalk, and cut with an axe. Anyone else may ask, "Why the hell would you do that? Masochisitic tendendies?"
0
seeguna's Avatar
Go4Expert Member
Code:
for (ln < hn; ln++)
	 {
	String formats = "%i  %f  %f\n";
	StdOut.printf(ln, ln * ln, ln * ln * ln);
	 }             //LINE 30
Replace the above coding with the followed one ,u will get answer
Code:
 for (;ln < hn; ln++)
	 {
	printf(" %f %f %f\n",ln, ln * ln, ln * ln * ln);
	 }             //LINE 30

Last edited by shabbir; 10Aug2007 at 08:57.. Reason: Code block - http://www.go4expert.com/forums/misc.php?do=bbcode#code
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Offtopic comment:
seeguna, Please use code block when you have code snippets in the posts.