A blog to help students to learn programming in various languages including C, C++, Java, Python and many more.

Subscribe For Free Latest Updates!

We'll not spam mate! We promise.

Saturday 16 January 2016



An array type is a data type that is meant to describe a collection of elements (values or variables), each selected by one or more indices (identifying keys) that can be computed at run time by the program. Such a collection is usually called an array variablearray value, or simply array. By analogy with the mathematical concepts of vector and matrix, array types with one and two indices are often called vector type and matrix type, respectively.

In order to effectively implement variables of such types as array structures (with indexing done by pointer arithmetic), many languages restrict the indices to integer data types (or other types that can be interpreted as integers, such as bytes and enumerated types), and require that all elements have the same data type and storage size. Most of those languages also restrict each index to a finite interval of integers, that remains fixed throughout the lifetime of the array variable. In some compiled languages, in fact, the index ranges may have to be known at compile time.
Information source: wikipedia.org


Program:->
Program ScreenShot
Output


#include <iostream.h>
using namespace std;
int main() {
   int arr[30], i, j, num, temp;

   cout<<"Enter no. of elements : ";
   cin>>num;
   cout<<"Enter "<<num<<" values : ";
   for (i = 0; i < num; i++) {
      cin>>arr[i];
   }
   j = num - 1;
   i = 0;  
   while (i < j) {
      temp = arr[i];
      arr[i] = arr[j];
      arr[j] = temp;
      i++;
      j--;
   }
   cout<<"\nResult after reversal : ";
   for (i = 0; i < num; i++) {
      cout<<arr[i]<<"   ";
   }
   return (0);
}

1 comments : Post Yours! Read Comment Policy ▼
PLEASE NOTE:
We have Zero Tolerance to Spam. Chessy Comments and Comments with Links will be deleted immediately upon our review.

  1. Array elements are reversed here by the swapping operation.Swapping is done by making use of an external variable temp.First using a for loop elements are entered in the array.Then using the variable temp elements are swapped and finally reversed.This is a valid code for reversing a number.Refer Best essay writing service to get expert advice from the professional writers.

    ReplyDelete



Copyright © 2016 - ProgrmIt - All Rights Reserved
(Articles Cannot Be Reproduced Without Author Permission.)
Design By : | Powered By: Blogger