<>

Array Input, Output, Deleting Index.


Create a program and do the following tasks:
  • Initialize an array of 10 integers to zero.
  • Input the array from the user.
  • Output the array.
  • Delete the element at INDEX 5 and move the rest of the items on the right, one place to the left. Place a zero at the last position. For example if the array is: 0,10,20,30,40,50,60,70,80,90. 
Then the array should become: 0,10,20,30,40,60,70,80,90,0.


#include <iostream.h>
void main()
{
     int a[10]={0},i;

     cout<<"Array is: ";

     for(i=0; i<10; i++)
          cout<<a[i]<<"  ";

     cout<<endl<<"Input the array: : ";

     for(i=0;i<10;i++)
          cin>>a[i];

     cout<<"Output Array is: ";

     for(i=0;i<10;i++)
          cout<<a[i]<<"  ";

     cout<<endl;

     cout<<"After Deleting 5th element: ";

     for(i=4;i<10;i++)
          a[i]=a[i+1];
    
     a[9]=0;

     for(i=0;i<10;i++)
          cout<<a[i]<<"  ";

     cout<<endl;
}
Rate this posting:
{[['']]}

0 comments:

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
TOP