1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

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

Discussion in 'C++' started by noob_dave, Aug 9, 2007.

  1. noob_dave

    noob_dave New 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 a moderator: Aug 9, 2007
  2. shabbir

    shabbir Administrator Staff Member

    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++)
     
  3. noob_dave

    noob_dave New 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.
     
  4. shabbir

    shabbir Administrator Staff Member

    You probably need to be working on "Hello World" program because I see you have written even the printf statement incorrect.
     
  5. noob_dave

    noob_dave New 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...
     
  6. DaWei

    DaWei New Member

    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?"
     
  7. seeguna

    seeguna New 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 a moderator: Aug 10, 2007
  8. shabbir

    shabbir Administrator Staff Member

    [COMMENT]seeguna, Please use code block when you have code snippets in the posts.[/COMMENT]
     

Share This Page