473,326 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

function square

Hi,
I'm beginner and have problems by using function square from math.h

Compajler:
Borland C++ 5.5.1 for Win32

Code:

#include <iostream.h>
#include <math.h>
int main() {
float r,k,x,y,z;
//long z;
cout <<"Enter x:";
cin >> x;
cout << "Enter y:";
cin >> y;
if (abs(x) != abs(y)) {
cout << "Enter r:";
cin >> r;
cout << "Enter k:";
cin >> k;
z = (square(r) * k) / (square(x) - square(y));
cout << "Rezults: " << z << endl;
}
else {
cout << "Funkcija nije definisana za date vrijednosti x i y \n";
return 0;
}
}

Compile Error:
Error E2268 Call to undefined function 'square'in function main()
Where I'm wrong?
Jul 19 '05 #1
4 88875

"Player" <al**@smartnet.ba> wrote in message
news:f6**************************@posting.google.c om...
Hi,
I'm beginner and have problems by using function square from math.h

Compajler:
Borland C++ 5.5.1 for Win32

Code:

#include <iostream.h>
#include <math.h>
int main() {
float r,k,x,y,z;
//long z;
cout <<"Enter x:";
cin >> x;
cout << "Enter y:";
cin >> y;
if (abs(x) != abs(y)) {
cout << "Enter r:";
cin >> r;
cout << "Enter k:";
cin >> k;
z = (square(r) * k) / (square(x) - square(y));
cout << "Rezults: " << z << endl;
}
else {
cout << "Funkcija nije definisana za date vrijednosti x i y \n";
return 0;
}
}

Compile Error:
Error E2268 Call to undefined function 'square'in function main()
Where I'm wrong?


There is no function square in math.h. Who told you that there was?

It's not hard to write you own of course.

john
Jul 19 '05 #2
Player writes:
I'm beginner and have problems by using function square from math.h

Compajler:
Borland C++ 5.5.1 for Win32

Code:

#include <iostream.h>
#include <math.h>
int main() {
float r,k,x,y,z;
file://long z;
cout <<"Enter x:";
cin >> x;
cout << "Enter y:";
cin >> y;
if (abs(x) != abs(y)) {
cout << "Enter r:";
cin >> r;
cout << "Enter k:";
cin >> k;
z = (square(r) * k) / (square(x) - square(y));
cout << "Rezults: " << z << endl;
}
else {
cout << "Funkcija nije definisana za date vrijednosti x i y \n";
return 0;
}
}

Compile Error:
Error E2268 Call to undefined function 'square'in function main()
Where I'm wrong?


There is no function square in <math.h> and you didn't provide a prototype
for one, either. The compiler correctly concluded that it had no such
function. Use your editor and examine math.h. The usual way to get a
square is x*x.
Jul 19 '05 #3
You may need the function "pow" in "math.h".

[
double pow(double x, double y);
]
Calculates x to the power of y.


T. Do
Jul 19 '05 #4

Player <al**@smartnet.ba> wrote in message
news:f6**************************@posting.google.c om...
Hi,
I'm beginner and have problems by using function square from math.h
There is no function called 'square' in the
C standard library. But of course it's simple
to write one.

Compajler:
Borland C++ 5.5.1 for Win32

Code:

#include <iostream.h>
#include <iostream>
using namespace std;
#include <math.h>
template <typename T>
T square(const T& value)
{
return value * value;
}
int main() {
float r,k,x,y,z;
file://long z;
cout <<"Enter x:";
cin >> x;


-Mike

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike Tammerman | last post by:
I want to serialize a function using its pointer. For example >>> s = """ .... def square(number): .... return number**2 .... """ >>> functions = {} >>> exec s in functions >>> f =...
2
by: cplusplus | last post by:
Hello, I have newbie question. I'm stuck on this current assignment. Write a program that prompts the user for two integer values, passes the values to a function where they are multiplied...
4
by: richardclay09 | last post by:
Hi Can someone please write some "compare and contrast" notes for "Template functions vs. function objects"? When to use one and not the other? For example, the TF square_f does the same thing as...
3
by: Gary Besta | last post by:
I am trying to add a simple case statement to a stored procedure or user defined function. However when I try and save the function/procedure I get 2 syntax errors. Running the query in query...
10
by: sjbrown8 | last post by:
I have the piece of code below, and when i try compiling with the line g++ 753075304.cpp I get the following error message: 753075304.cpp: In function 'int main()': 753075304.cpp:29: error:...
2
by: logicode | last post by:
I have a program that works fine but when I put in a zero the sign is supposed to return zero but doesn't #include <iostream.h> #include <stdlib.h> ...
7
by: Protoman | last post by:
Is this an efficient way to integrate an explicit function of x from a to b: #include <iostream> using namespace std; class Integrate { public: Integrate(long double (*f)(long double&...
5
by: WanHongbin | last post by:
#include <stdio.h> double square(); /*without declare main() { double s; s = square(2); printf("%g\n", s); }
8
by: HighlightReel44 | last post by:
I need help writing a program which will display a menu with options Square, Cube, Fourth Power and Quit. Accept S,C,F,Q from the user non case sensitive. Use integers between 0 and 100 and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.