rabbinur

array n summation

Aug 13th, 2012
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <conio.h>
  3. //replaces every n occurrencies with 7
  4. #define n 10
  5.  void main()
  6. {
  7.  int i, total=0, y[n]={1,2,3,4,5,6,7,8,9,10};
  8.  clrscr();
  9.  for(i=0; i<n; i++)
  10.  //display the array content
  11.  {
  12.   cout<<y[i]<<" ";
  13.   total=total+y[i];
  14.  }
  15.   //display the total
  16.   cout<<"\n sum of 10 in an array is ="<<total;
  17.  getch();
  18. }
Advertisement
Add Comment
Please, Sign In to add comment