Sum of as many numbers as you Require

08:39 0 Comments A+ a-

Problem:
Write a program that calculates the sum of real numbers. Your program should keep taking values and adding them unless user presses -999. Your program should display the sum before the program finishes.
Solution:
# include <iostream> using namespace std; int main() { double num; double sum=0; cout<<"Enter the number"<<endl; cin>>num; while(num!=-999){ sum+=num; cout<<"Enter the number again"<<endl; cin>>num; } cout<<"The sum of all the Real numbers entered is:"<<sum<<endl; return 0; }