write a program to store n numbers to an array and display them

Size of array is taken from user as n. then n numbers are stored in array..Array is displayed as output.


Select To use this code as it is.. select and copy paste this code into code.cpp file :)



  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. int ar[10],n;
  7. cout<<"Enter size of the array: ";
  8. cin>>n;
  9. cout<<"Enter array element: "<<endl;
  10. for(int i=0;i<n;i++)
  11. //Coding by: Snehil Khanor
  12. //http://WapCPP.blogspot.com
  13. {
  14. cout<<"Enter element "<<i<<": ";
  15. cin>>ar[i];
  16. }
  17. cout<<"Elements of array: "<<endl;
  18. for(i=0;i<n;i++)
  19. cout<<"Element at index number "<<i<<" is: "<<ar[i]<<endl;
  20. getch();
  21. }

Check out this stream