Answer:
Below program is in C++ Programming Language
Explanation:
Code explanation is in comments, the line starts with // .
// Import all necessory files
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
int main()
{
//Declaring input string to get data from user
string myinput="";
// getline will get input string from user through command prompt
getline(cin, myinput);
//stringstream will be used to get one by one inputed number //seperated by space
//stringS is the name we set for stringstream
stringstream stringS(myinput);
// num will be used to get space seperated number from stringstream
int num = 0;
int sum=0;
// we need to count total numbers enterd by user to get the average
int count=0;
// this if is to prevent any error if user does not provide any number
if(myinput == ""){
cout<< "Nothing entered";
return 0;
}
// while loop iterates up to total inputed numbers entered by user
while (stringS >> num) {
sum += num;
count++;
}
// Output the desired result
cout << "Sum :"<<sum << "\n";
cout << "Average :" << sum/count <<endl;
return 0;
}