Hi all,

I want to just write a simple test case for a method which multiply two numbers.

I am using the Linux platform.
in the web (http://cpptest.sourceforge.net/tutorial.html) there are some examples. But I do not know what is the header file that should include.

please can anyone help me...

Recommended Answers

All 2 Replies

well you may need <cmath>, ofcourse <iostream> well that is what i can think of at the moment..but depending on the functions you are going to use, only <iostream> will be needed. You will need to identify the errors from your code or give us a clue about what you have done

make a file using any text editor (emacs, vi, gedit) called test.cpp

#include <iostream>
using namespace std;

double Multiply(double a, double b)
{
return a*b;
}

int main()
{
double c = Multiply(10,2);
cout << "10 * 2 = " << c << endl;
return 0;
}

then to compile, from a terminal type

g++ test.cpp -o test

then to run the program

./test

hope this helps

dave

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.