#include <iostream>
usingnamespace std;
int main()
{
int a,b,c,d,e; //Digits
int x; //Number
int am; // Amount of digit 2
cout << "Type in your first number: "<<endl;
cin >> x;
cout << "Your number digits are: "<<endl;
a = x / 10000;
b = (x / 1000) % 10;
c = (x / 100) % 10;
d = (x / 10) % 10;
e = x % 10;
cout <<"1. "<<a<<endl;
cout <<"2. "<<b<<endl;
cout <<"3. "<<c<<endl;
cout <<"4. "<<d<<endl;
cout <<"4. "<<e<<endl;
am = 0;
if (a = 2)
am= am + a;
if (b = 2)
am = am + b;
if (c = 2)
am = am + c;
if (d = 2)
am = am + d;
if (e = 2)
am = am + e;
cout <<"Amount of digits 2: "<<am<<endl;
system("PAUSE");
return 0;
}
The amount always keeps the same. 2.
What i've done wrong, anyone could help me please? Im a begginer, totally new in this, so i don't know what ive done wrong. Waiting for help, thanks.