Is this how you add the digits of multiple numbers? (units, tens, hundreds)

  addition, c++, digits, extract, operators

I just wanna make sure whether this code is good or it needs improvement. What do you all think?

#include <iostream>
using namespace std;

    u = (a%10+b%10+c%10+d%10+e%10+f%10);
    t = (a / 10 % 10 + b / 10 %10 + c / 10 % 10 + d / 10 %10 + e / 10 % 10 + f / 10 %10);
    h = (a / 100 % 10 + b / 100 % 10 + c / 100 % 10 + d / 100 % 10 + e / 100 % 10 + f / 100 % 10);
    
    cout << "The sum of the first digit is: " << u << "n";
    cout << "The sum of the second digit is: " << t << "n";
    cout << "The sum of the third digit is: " << h ; 

Source: Windows Questions C++

LEAVE A COMMENT