# 3 small char problems

This is a discussion on 3 small char problems within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by rags_to_riches Odd...CS 575 implies that you are not an amateur or a beginner, as stated in your ...

1. Originally Posted by rags_to_riches
Odd...CS 575 implies that you are not an amateur or a beginner, as stated in your first post. Does your school do something wacky, like start you off in 500-level courses, with 100-levels being the final year courses? Just a non-standard nomenclature, AFAIK. Heck, most 500-level courses are grad school courses.

(Just an aside...oddities fascinate me)
well the college I go to offers many programming classes, the teachers itself do make fun of the classes as my next semmester class is cs 570 which is java but you start at 575 which gives you the abcs of programming in which i am stuck

2. Originally Posted by elpedoloco
Awesome, so for my problem I understand that:
x takes value of 100s
y takes value of 10s and
z takes value of 1s

I tried to do the conversion as follows
digit =(x+100)+(y+10)+(z+1) however my silly attempt did not work.
It would be (x * 100) + .... Come on now, turn your brain on.

4. Originally Posted by AndrewHunter
It would be (x * 100) + .... Come on now, turn your brain on.
Sorry Andrew, I do appreciate your help, I am just getting some weird compiler outputs I keep getting big numbers;
I understood how each character takes place depending on the digit and thus we must multiply that char by its digit, however I know that I must tell the compiler to
perform an operation with the asquii code overall numbers so it does not confuse my value for one of theirs.
Thats where I am currently stuck at the moment, Thanks again Andrew you've been greater help than my teacher.

Code:
```

//  CS 575 HW 3

#include <iostream>
#include <string>
using namespace std;

void c();
void d();
void e();
void f();
void g();
void h();

bool die( const string & msg );

int main(){

c();
d();
e();
f();
g();
h();

}

void c(){
char x,y,z;
int digit;
cin>>x>>y>>z;
digit=(x*100)+(y*10)+(z*1); // this operation seems to get the value of asquii code of a,b,c and then multiply by 100,10,1
cout << digit;

}    //  c

void d(){

}    //  d

void e(){
}    //  e

void f(){

}    //  f

void g(){

}    //  g

void h(){
}    //  h

bool die( const string & msg ){
cerr <<endl <<"Fatal error: " <<msg <<endl;
exit( EXIT_FAILURE );
}   //  die```

5. I see what you are saying now. A simple ASCII to decimal conversion is to subtract '0' from the number. So if you have char '5', to get number 5 you would do: '5'-'0'.( That is the char zero. )So in your case:

((x-'0')*100) + ....

6. Originally Posted by AndrewHunter
I see what you are saying now. A simple ASCII to decimal conversion is to subtract '0' from the number. So if you have char '5', to get number 5 you would do: '5'-'0'.( That is the char zero. )So in your case:

((x-'0')*100) + ....
Thanks Andrew you been great help.

7. a,b,c,d,e,f,g,h ... best function names ever!

8. Originally Posted by iMalc
a,b,c,d,e,f,g,h ... best function names ever!
It correlates with his assignments. I don't think he has a choice.

Page 2 of 2 First 12