C++ Programming Blog

 
 
 

Image

 #include<iostream.h>
 #include<conio.h>

 void modify_array_element(int);
 void modify_array(int [],int);
 void print_array(int [],int);

 main()
    {
       clrscr();

       const int array_size=10;
       int array[array_size]={0,1,2,3,4,5,6,7,8,9};

       cout<<\"\\n The contents of the array before modification are : \"<<endl;
       print_array(array,array_size);

       getch();
       clrscr();

       cout<<\"\\n The contents of the array after modification are : \"<<endl;
       modify_array(array,array_size);
       print_array(array,array_size);

       cout<<\"\\n\\n The value of array[5] before modification is = \"<<array[5];
       modify_array_element(array[5]);
       cout<<\"\\n\\n The value of array[5] after modification is = \"<<array[5];

       getch();
       return 0;
    }


 //-------------------------  print_array(int [],int)  -------------------//


 void print_array(int array[],int size)
    {
       cout<<\"\\n     Elements :\"<<\"\\t\\t     Value:\"<<endl;

       for(int count=0;count<size;count++)
      cout<<\"\\t\"<<\" array [\"<<count<<\"]\"<<\"\\t\\t\"<<array[count]<<endl;
    }


 //-------------------------  modify_array(int [],int)  ------------------//


 void modify_array(int array[],int size)
    {
       for(int count=0;count<size;count++)
      array[count]+=2;
    }


 //--------------------  modify_array_element(int)  ----------------------//


 void modify_array_element(int array_element)
    {
       array_element+=2;
    }