Question:
c lanauage error "undefined reference to 'your functions'". Plzz help!?
Eric
2013-10-15 18:30:41 UTC
Hello, I tried compiling my code and i got this:
(.text+0x36): undefined reference to 'questions'

This is my code:

#include
#include
#include

float question1(float hours, float payRate, int type);
int question2(float error);
int question3(numYears);

int main()
{
question1(10,100,3);
question2(20);
questions(2013);
return 0;
}

float question1(float hours, float payRate, int type) // calculating the total pay for a worker.
{
float pay;
printf("Number of hours: %f\n hours", hours);
printf("\n");
printf("The pay rate is:$ %f\n", payRate);
printf("\n");


if (type == 1)
{
printf("Type of worker: hourly worker");
printf("\n");
pay = (payRate*hours);
printf("The total pay is:$ %f\n", pay);
}
else
if (type == 2)
{
printf("Type of worker: commission worker");
printf("\n");
pay = (0.057*payRate*hours);
printf("The total pay is:$ %f\n", pay);
}
else

if(type == 3)
{
printf("Type of worker: manager");
printf("\n");
pay = 550*(hours/168);
printf("The total pay is: $ %f\n", pay);
}
return 0;
}


int question2(float error) // Find the number of terms to calculate the percent difference between an infinite series of pi and its defined value.
{
float defined_value;
defined_value = 3.141592635;
printf("The defined value of pi is: %f\n", defined_value);
float x = error / 100.0;
float a;
float b;
float c;
float difference;
int count = 0;
while (difference < x)
{
b = 4/((2*count)-1);
if( count %2 ==1)
{
a = -1;
c = a*b;

}
else
{
a = 1;
c = a*b;
}

difference = defined_value - c;
count ++;
}
printf("The estimated value is: %f\n", c);
printf("The number of terms used is: %d\n", count);

return 0;
}

int question3(int numYears) // Find the world population in years starting from yr 2013
{

float a = 7e9;
printf("The population is currently: %f\n", a);
while( a!= 2*a)
{
a = a*1.018;
numYears = numYears+1;
printf(" In the year %d\n,", numYears);
printf("the population is: %f\n", a);
printf("\n");

}

if (a = 2*a)
{
printf("The population doubled in %d\n", numYears);
printf("THe population at that time is: %f\n", a);

}

return 0;


}


Can someone point out what i did wrong?
Thanks!
Three answers:
James Bond
2013-10-15 21:26:42 UTC
May be change declaration of question3 function at the begining as

int question3(int numYears);//<----------------



Also



int main()

{

question1(10,100,3);

question2(20);

question3(2013); //<---------------------

return 0;

}
2013-10-16 01:40:50 UTC
First this is C++, that is important not to confuse people who can help you.



It would be much easier to help if you posted the exact errors like this:

error C2065: 'numYears' : undeclared identifier

error C3861: 'questions': identifier not found



Here are you actual errors and problems.

Line 7: int question3(numYears); //You didn't give numYears a data type

Line 13: questions(2013); //You didn't define or prototype a questions() function, you probably meant the questions3() function.

Line 90: int question3(int numYears) //If you fix the line 7 error, this will go away



To get line numbers: TOOLS -> Options... -> Text Editor -> All Languages -> General -> [x] Line numbers. Also posting your code on pastebin and then linking it with your post is a better way for others to read your code.



You also have a ton of warnings of about converting float values. If you are using float data types for operations in your functions, it would be much better to return them as float data types and not int data types.
Richard
2013-10-16 01:33:44 UTC
should be question3(2013) instead of questions(2013) in main function


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...