C++ Programming Blog

 
 
 

Image

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

 main()
    {
       clrscr();

       int array[10]={0};

       cout<<\"\\n The contents of the array are : \"<<endl;
       cout<<\"\\n     Elements :\"<<\"\\t\\t     Value:\"<<endl;

       for(int count_1=0;count_1<10;count_1++)
      {
         cout<<\"\\t\"<<\" array [\"<<count_1<<\"]\"<<\"\\t\\t\"<<array[count_1]
                                      <<endl;
      }

       getch();
       clrscr();

       int sum=0;

       for(int count_2=0;count_2<10;count_2++)
      {
         array[count_2]=count_2*2+2;
         sum+=array[count_2];
      }

       cout<<\"\\n The contents of the array are : \"<<endl;
       cout<<\"\\n     Elements :\"<<\"\\t\\t     Value:\"<<endl;

       for(int count_3=0;count_3<10;count_3++)
      {
         cout<<\"\\t\"<<\" array [\"<<count_3<<\"]\"<<\"\\t\\t\"<<array[count_3]
                                      <<endl;
      }

       cout<<\"\\n The sum of the array is = \"<<sum<<endl;

       getch();
       return 0;
    }