Saturday, February 21, 2009

Modular Facility of C++

Like any programming languages, the use of modular programming is enforced. In C or C++, we call this as a function.

We have to however declare function/s before use and this declaration must be similar to how we define functions.

Check this sample program:

[+/-] show/hide

using namespace std;
float convert(float feet);
float xfeet;

cout<<"input values for feet:";
cout<<"Equivalent in inches: "<
float convert(float feet)
{return feet*12.00;}

You can write this in C by replacing the input and output functions with scanf() and printf() and the predefined library of stdio.h.

No comments: