More Functions
From Wikiversity
|
Please help develop this page
This page was created, but so far, little content has been added. Everyone is invited to help expand and create educational content for Wikiversity. If you need help learning how to add content, see the editing tutorial and the MediaWiki syntax reference. To help you get started with content, we have automatically added references below to other Wikimedia Foundation projects. This will help you find materials such as information, media and quotations on which to base the development of "More Functions" as an educational resource. However, please do not simply copy-and-paste large chunks from other projects. You can also use the links in the blue box to help you classify this page by subject, educational level and resource type. |
|
functions are building blocks of C++ A function is a named part of a program that can be invoked from other parts of the program as often needed.Consider the following program that accepts a number and prints its cube:-
#include<iostream.h>
using namespace std;
float cube(float);
float cube(float a)
{
return a*a*a;
}
int main()
{
float num;
cout << "Enter a number:";
cin >> num;
cout << "The cube of" << num << "is " << cube(num)<< "\n";
system("pause");
return 0;
}
output of the program will be-
Enter a number : 19
The cube of 19 is 729
[edit] Where To Go Next
| Topics in C++ | ||
| Beginners | Data Structures | Advanced |
|---|---|---|
| Part of the School of Computer Science | ||

