Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Hi all.. If i knew this website existed it would have saved me hours of useless (http://www.go4expert.com/forums/hi-i-website-existed-saved-hours-useless-t5762/)

noob_dave 9Aug2007 17:00

Hi all.. If i knew this website existed it would have saved me hours of useless
 
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;
}


shabbir 9Aug2007 17:06

Re: Hi all.. If i knew this website existed it would have saved me hours of useless
 
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++)

noob_dave 9Aug2007 17:10

Re: Hi all.. If i knew this website existed it would have saved me hours of useless
 
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.

shabbir 9Aug2007 17:28

Re: Hi all.. If i knew this website existed it would have saved me hours of useless
 
You probably need to be working on "Hello World" program because I see you have written even the printf statement incorrect.

noob_dave 9Aug2007 19:14

Re: Hi all.. If i knew this website existed it would have saved me hours of useless
 
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...

DaWei 10Aug2007 03:42

Re: Hi all.. If i knew this website existed it would have saved me hours of useless
 
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?"

seeguna 10Aug2007 08:12

Re: Hi all.. If i knew this website existed it would have saved me hours of useless
 
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


shabbir 10Aug2007 08:58

Re: Hi all.. If i knew this website existed it would have saved me hours of useless
 
Offtopic comment:
seeguna, Please use code block when you have code snippets in the posts.


All times are GMT +5.5. The time now is 10:53.