Tuesday, January 11, 2011

CPP_Function array 1 dimention

Code:
**********************************************
//Function of Array 1 dimention
#include<iostream>
using namespace std;
int main()
{   float x[20];
    int N,getdata(float*);
    void DisplayArray(float*,int),Displayelement(float);
    N=getdata(x);
    DisplayArray(x,N);
    Displayelement(x[N-1]);
    return 0;
}
int getdata(float A[])
{   int No;
    cout<<"\nInput Number of data: ";
    cin>>No;
    for(int i=0;i<No;i++)
    {   cout<<i+1<<"): ";
        cin>>A[i];
    }
    return No;
}
void DisplayArray(float A[],int N)
{   cout<<"\nOutput Array\n";
    for(int i=0;i<N;i++)
    {   cout<<i+1<<"): "<<A[i]<<endl;}
}
void Displayelement(float a)
{   cout<<"\nOutput only one element of the end of array\n";
    cout<<"x :"<<a<<endl;
}
**********************************************

No comments:

Post a Comment