Hello all
can this code be written with a recursive function??
if it could, can anyone show me?? thanks!!
int main()
{
string olo("I love C++");
int k1, k2=0;
for (k1=0;k1<olo.length();k1++)
{ k2=k2+olo.at(k1);
}
cout<<k2<<endl;
cout << "decimal: " << k2 << endl;
// print hex with leading zeros
cout << "hex : ";
for (int i=2*sizeof(int) - 1; i>=0; i--)
{
cout << "0123456789ABCDEF"[((k2 >> i*4) & 0xF)];
}
cout << endl << endl;
return 0;
}
Laura
can this code be written with a recursive function??
if it could, can anyone show me?? thanks!!
int main()
{
string olo("I love C++");
int k1, k2=0;
for (k1=0;k1<olo.length();k1++)
{ k2=k2+olo.at(k1);
}
cout<<k2<<endl;
cout << "decimal: " << k2 << endl;
// print hex with leading zeros
cout << "hex : ";
for (int i=2*sizeof(int) - 1; i>=0; i--)
{
cout << "0123456789ABCDEF"[((k2 >> i*4) & 0xF)];
}
cout << endl << endl;
return 0;
}
Laura