anonymous
  • anonymous
I want to convert a char to int like '7' to 7 (in C++) but every time I try it gives me its ASCII value. Basically I just want to multiply two characters like '7' * '7' = 49.
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
jagatuba
  • jagatuba
I solved a similar problem to this in Java by subtracting the appropriate amount from the ascii value. So numerals 0-9 ascii values are 30-39, so simply subtract 30 from your ascii value and assign it to the variable that you want. Pseudo code: Print "Enter a number: " Input numString Parse numString to numAscii numInt=numAscii-30 numInt=numInt*7 Print numInt
jagatuba
  • jagatuba
You could also mod 10 the ascii value.
anonymous
  • anonymous
for the '0' to '9' ASCII characters, just subtract '0' (the character) from it, because character literals in C (and i think C++ as well) are just integer values of their ASCII encoding. for example: http://ideone.com/noXGk

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

jagatuba
  • jagatuba
Thanks agdg. I knew you'd pipe in with something useful.

Looking for something else?

Not the answer you are looking for? Search for more explanations.