Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Calling Functions

Posted on 2000-04-19
Medium Priority
217 Views
What is the right way to call a function in a program?
0
Question by:SBuntin
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• Learn & ask questions
• 3

LVL 22

Accepted Solution

nietod earned 120 total points
ID: 2731978
you use the functin name a left parenthises, then any parameters, then a right parenthesis.

example follows.
0

LVL 22

Expert Comment

ID: 2731985
// no parameters.
int GetZero()
{
return 0;
}

// 1 parameter.
int Increment(int i)
{
return i +1;
};

// 2 parameters.
int Add(int x,int y)
{
return x + y;
};

*    *    *

int x = GetZero();
int y = Increment(x);
int z = Add(x,y);

Let me know if you have any questions.
0

Author Comment

ID: 2735885
I am having problems linking or something...I really don't know what it is saying...

Here is my problem whats wrong:

#include <iostream.h>
#include <math.h>

int main()
{
int convert;

cout << "What would you like to convert to?\n";
cout << "1. Degrees to Radians";
cout << "2. Radians to Degrees";
cin >> convert;

if (convert == 1)
{
// Input
cout << "Degrees? ";
cin >> degree;

// Calculations and Output
}

if (convert == 2)
{
// Input
cout << "Radians? ";

// Calculations and Output

}

return 0;
}

{
float pi = 22 / 7;
float totalb = degree * (pi/180);

}

{
float pi = 22 / 7;
float totalB = radian * (180/pi);

}
0

LVL 22

Expert Comment

ID: 2742552
The forward declarations of the 2 conversion functions do not match the function definitions.  Both the definitions take floats as parrameters and return floats as return values.  but your forward definitions take no parameters and return no values.  You should change them to

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
###### Suggested Courses
Course of the Month8 days, 15 hours left to enroll

#### 721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.