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 :)
Printable View
Your school is weird :)
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
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) + ....
a,b,c,d,e,f,g,h ... best function names ever!