hi everyone,
I am trying to initialize array in main method, and insert value in array in another method named "popArr()", in last print array in "printArr()" method. But its not working and i am getting errors. The environment i am using borland c++. The code is as follows.
#include <iostream.h>
#include <conio.h>
void popArr();
void printArr();
void main()
{
int arr[10];
//methods
popArr();
printArr();
getch();
}
void popArr()
{
//get values and store in array
cout << "Enter numbers in array :" << endl;
for(int i=0; i<10; i++)
{
cin >> arr[i];
}
}
void printArr()
{
//print array values
cout << "Array : " << endl;
for(int i=0; i<10; i++)
{
cout << arr[i] << " ";
}
}
Anyone please help. I will highly appreciate. Thnx.