function problem

L

Learning Learner

I know this must have some simple answer but I'm having trouble with
this function I wrote.

stdio.h
math.h

double relstr (double x,double y)
{double n;
n=x/y;
printf("%f",(return n;));}

I dunno.
 
I

Ian Collins

I know this must have some simple answer but I'm having trouble with
this function I wrote.

stdio.h
math.h

double relstr (double x,double y)
{double n;
n=x/y;
printf("%f",(return n;));}

I dunno.

So I see. What on earth is that supposed to do?
 
P

Peter Nilsson

Learning Learner said:
I know this must have some simple answer but I'm having
trouble with this function I wrote.

stdio.h
math.h

Is that what's in your source, or are you using a bad
editor to post to usenet?
double relstr (double x,double y)
            {double n;
              n=x/y;
              printf("%f",(return n;));}

The return keyword marks a statement, not an expression.

You can't use a statement as a form of expression in standard C.
Are you learning from a reference book or tutorial? It seems
you're trying to learn C by guesswork. My advice is... DON'T!
It's the worst language for that!
 
O

Oliver

I know this must have some simple answer but I'm having trouble with
this function I wrote.

stdio.h
math.h

double relstr (double x,double y)
            {double n;
              n=x/y;
              printf("%f",(return n;));}

I dunno.

I also dunno.

printf("%f", (return n;));

"return n;" will always run earlier than printf(), so?

double relstr(double x, double y)
{
double n;

n = x/y;
printf("%f", n);
return n;
}

is above you want?
 
K

Keith Thompson

Oliver said:
I also dunno.

printf("%f", (return n;));

"return n;" will always run earlier than printf(), so?

No, "return n;" will not run at all, because it's a syntax error.
"return n;" is a statement, and statements cannot appear within
expressions.

[...]
 
R

Richard Bos

Kenneth Brody said:
ITYM "INTERCAL". It's an acronym meaning "Compiler Language With No
Pronounceable Acronym", not a proper noun.

I've never understood what's supposed to be so unpronouncable about
Clwnpa. Any Welshman could tell you exactly how that is pronounced.

Richard
 
J

Joachim Schmitz

Richard said:
I've never understood what's supposed to be so unpronouncable about
Clwnpa. Any Welshman could tell you exactly how that is pronounced.

Looks like a common welsh first name :cool:

Bye, Jojo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,137
Messages
2,570,797
Members
47,344
Latest member
KamCrowthe

Latest Threads

Top