Functions
Functions: A brief Introduction in C++
Functions are used to make it easier to understand the work ,The Function can be is a part of a program , that can be called any where in the main program, so that we don’t have to write one task again and again
It structure is
Exercise 1;
Writing a Function for Addition
| #include<iostream>
using namespace std; int addTwonumbers(int A, int B) { int C; C=A+B; return C; } main() { int A,B,C; cout<<“Enter the Values to be enterd “<<endl; cin>>A>>B; C=addTwonumbers(A,B); cout<<“output is “<<C; } |
Function to multiply three numbers
| #include<iostream>
using namespace std; int mul(int a, int b, int c) { int d; d=a*b*c; return d; } main() { int A,B,C; cout<<“Enter the Values to be multiplied “<<endl; cin>>A>>B>>C; mul(A,B,C); cout<<“output is “<< mul(A,B,C); } |
First published on fatsup.wordpress.com ↗

