I'm practicing lambda expressions right now, this program I made is getting the weighted average of a subject, the first lambda expression 'get_avg' is getting the data while the process is the 'sum_avg', when it runs the sum_avg is outputting '-nan(ind)' and it is not the answer I wanted.
#include<iostream>
#include<thread>
using namespace std;
int main() {
float m = 0, w = 0;
auto get_avg = [](float m, float w) {
cout << "ENTER THE GRADE: ";
cin >> m;
cout << "ENTER THE UNITS: ";
cin >> w;
return m, w;
};
get_avg(m, w);
auto sum_avg = [](float m,float w){
cout << "THE WEIGHTED AVERAGE IS :" <<m*w/w << endl;
};
sum_avg(m,w);
system("PAUSE");
return 0;
}
Aucun commentaire:
Enregistrer un commentaire