Pages

Sunday, September 01, 2013

Write a program of Adding a list of number in C++

Add a list of integer from keyboard

Source Code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
   #include <iostream.h>
   #include <conio.h>
   using namespace std;
   int main ()
     {
       int x;
       int sum = 0;
       
      cout << " Enter your number: <EOF> to stop \n";
      while (cin >> x)
           sum += x;
      cout << "\n The total number: " << sum << endl;
      getch ();
      return 0;
             } // main       

Result:


 Enter your number: <EOP> to stop
15
22
3^d
 The total is: 40

No comments:

Post a Comment