Answers for "enter many numbers and add the ones digit tens digit and hundreds digit c++"

C++
0

enter many numbers and add the ones digit tens digit and hundreds digit c++

#include <iostream>
using namespace std;

int main()
{
	int a,b,c,d,e,f;
	int u, t, h;
	cout << "Enter 6 numbers: \n" ;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	cin >> f;
		
	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 ; 
	
}
Posted by: Guest on October-20-2021

Code answers related to "enter many numbers and add the ones digit tens digit and hundreds digit c++"

Browse Popular Code Answers by Language