Posts

Showing posts from June 30, 2013

C++ User defined Function in Array Programming.

1. C++ Function Program to Sum all the digits from an Integer Array. The below program will work as the points mention hereafter: Explanation: the main( ) function will call the user defined function named arraysum(). the prototype of arraysum() is interger and it will pass two parameter(int[],int). The first part is for array and the second part is for length of the given array. The arraysum() function receives all the data and doing sum using looping technique and print inside the function. Here function does not returns anything. It only receives value from main( ) program. #include<iostream> #include<conio.h> using namespace std; int arraysum(int[],int); int main() { int n,j; cout<<"Enter the length of the array"<<endl; cin >>n; //initializing the array length int x[n]; //fill up the array using integer data cout<<"Enter the elements :"<<endl; for(j=0;j<n;j++) {  cin>>x[j]; } //call the fu