W.A.P. C++

WAP | CPP | Programs in C++ | C++ Solutions

Write a program to find sum of array elements

Size of array is taken from user..Numbers are stored in the array.. and sum is determined of the elements of array..
Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. int ar[10],n,s=0;
  7. cout<<"Enter size of the array: ";
  8. cin>>n;
  9. cout<<"Enter array element: "<<endl;
  10. for(int i=0;i<n;i++)
  11. {
  12. cout<<"Enter element "<<i<<": ";
  13. cin>>ar[i];
  14. }
  15. //Coding by: Snehil Khanor
  16. //http://WapCPP.blogspot.com
  17. cout<<"Elements of array: "<<endl;
  18. for(i=0;i<n;i++)
  19. cout<<"Element at index number "<<i<<" is: "<<ar[i]<<endl;
  20. ///For adding all elements///
  21. for(i=0;i<n;i++)
  22. s=s+ar[i];
  23. cout<<"Sum of elements: "<<s;
  24. getch();
  25. }



About WAP C++

Here you'll find a wide range of programs' solution ranging from beginer level to advanced level.
All programs here are made, compiled and tested by me..and are running absolutely fine.. still if you find any bug in any program do let me know :)


Subscribe via email

Enter your email address:

Delivered by FeedBurner

my Binary Log

Blog Archive

eXTReMe Tracker