rabbinur

value and sum finding

Aug 14th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. //value and sum finding
  2. #include <iostream.h>
  3. #include <conio.h>
  4.  void main()
  5.  {
  6.   int a[5];//variable declaration
  7.   int n=0;//value in an array
  8.   clrscr();
  9.   while(cin>>a[n]){
  10.    n++;
  11.    }
  12.  
  13.     int sum=0, i;
  14.     for(i=0; i<n; i++)
  15.     sum=sum+a[i];
  16.     cout<<sum<<endl;
  17.     getch();
  18.  }
Advertisement
Add Comment
Please, Sign In to add comment