Help me please, I don't really get how to write this into pseudo code.
I need to submit this evening
#include <iostream>
using namespace std;
int main()
{
string x;
int total(0), jumlah_genap(0), jumlah_ganjil(0), digit_genap(0), digit_ganjil(0);
cout << "Please provide a number to validate" << endl;
cin >> x;
for (int i=1; i<=8; i++)
{
if (i%2 == 0)
{
digit_ganjil=x[i-1]-'0';
jumlah_ganjil=jumlah_ganjil+digit_ganjil;
}
else
{
digit_genap=(x[i-1]-'0')*2;
digit_genap=digit_genap%10+digit_genap/10;
jumlah_genap=jumlah_genap + digit_genap;
}
}
total=jumlah_ganjil+jumlah_genap;
cout << endl <<"The number your provided is ";
if (total%10==0)
cout << "valid" << endl;
else
cout << "invalid" << endl;
return 0;
}
Last edited on