A2RAYA
You've done us proud boys
hey all...if anyone here knows their c++ programs..i need some help with a couple of programs i'm writing for uni
1)
now i can't see a prob with this but then i compile it and it says:
error C2601: 'g' : local function definitions are illegal
error C2601: 'g_2' : local function definitions are illegal
any ideas?
cheers
1)
Code:
//prac week 13-Q1
//program will ask the user to enter a value (x) and then use it in one of two functions,
//depending on its size,to return a value for the function g(x)
#include <iostream.h>
#include <stdlib.h>
#include <math.h>
double g(double x1),
double g_2(double x2);
void main()
{
double x;
cout<<"enter a number: ";
cin>>x;
if(x<0)
{
g(x);
}
if(x>=0)
{
g_2(x);
}
//--------------------------------------------------------------------------------
double g(double x)
-->{
cout<<"g(x)= 0"<<endl<<endl;
}
//--------------------------------------------------------------------------------
double g_2(double x)
-->{
cout<<"g(x)= "<<(6*exp(x-3))<<endl;
}
return;
}
error C2601: 'g' : local function definitions are illegal
error C2601: 'g_2' : local function definitions are illegal
any ideas?
cheers
Last edited by a moderator: