What is the exact statement or code for reading an integer alone
being entered and if it is not an integer being entered it will
disregard the next instruction or leave any invalid message in the
output of your program?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks a lot sir!im sorry for what i said for being misinterpreted.
all the informations you have given to me are worthy and its a
great help,i appreciated a lot.i know im new to this language but
i think,its never too late to learn.
Mackmellow
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-08-23
One statement to do all that!?
There is more than one way, and it is certainly more than one statement. The answer would also likely depend on whether you wanted to do it in C or C++. Either way you need to specify your requirements less ambiguously.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This looks like another homework problem that you are trying to obscure by
rewording it.
You might be better off if, instead of trying to hide that things are
homework, you provided the correct statement of the problem, and
your code and or thinking about how you have started to address the
problem.
We are willing to help you with doing your homework, but this is
not a place to simply post the problem and wait for someone to
provide you with an answer.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your information about the codes but
i just like to know you that all my comments that
has been posted are not homeworks, it is just an
experimental reason for i just love to learn programming.
i already earned my degree in engineering,im not a student anymore
and im now starting to self-study those things.
For further comments on my programming,i expect and hope for
your help and guidelines.
thankszzz....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Seems like you're mad at me buddy!.You're right, very few people
learn anything from looking at someone's code but im not
copying your code all the way,im just getting your idea in order
to apply it in my experimental study in C,im new to this language and has just started to self-study cause im not an IT Prof.I just hope your understanding cause i just need a little help.
i hope im not forcing you to answer my questions cause i want
some help which is heartily given not by your pride,that,if you
would'nt mind.
Could you please give me an idea on object-oriented programming in C++ by giving its algorithm,data structure,and a simple example.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not mad, but I do think you are misinerpreting what this place is. It
is not a paid help line. You should not feel comfortable posting code,
and simply saying "Correct this". You should not feel comfortable asking
someone to put a lecture together for you, on a topic that a number of
free books and online tools cover.
Specific questions, yes. "Teach me about OO" is something that would
cover several lectures in school and is beyond the scope of what you
should feel comfortable asking complete strangers to do for you for
free.
Now:
In the thread titled "Please Read Before Posting a Question" is a section on
useful links - it has a number of links to free online books and other resources
that can help you in your quest.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Now, you can understand what I have told you in terms of understanding this
place, or you can just decide I am so mean old guy who doesn't want to help
you.
Wayne (issomean)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To me - my simple minded framework is this - an object is a way of packing together
data, and code for processing that data, as well as interfacing to the rest of the world
into a convenient structure. Think of it as a super type.
You can then create instances of this type - just like you make instances of a type
integer in line of code:
int waynesamoron = 0;
More than that, these types can be used to create other types through inheritance.
Now, how is this all used. Well, to write "Hello World", it probably doesn't do
you much good. On the other hand, if you are writing code in which different
things interact - you can, at times, model those things by objects.
Here is a stupid example of a one file program that creates a class, and then some
instances of that class. Yes, I "borrowed" it from a tutorial...
include <iostream>
using namespace std;
class Stack
{
int stk[100];
int top;
public:
Stack(): top(0) {}
~Stack() {}
void Clear() {top=0;}
void Push(int i) {if (top < 100) stk[top++]=i;}
int Pop()
{
if (top > 0) return stk[--top];
else return 0;
}
int Size() {return top;}
};
What is the exact statement or code for reading an integer alone
being entered and if it is not an integer being entered it will
disregard the next instruction or leave any invalid message in the
output of your program?
Thanks a lot sir!im sorry for what i said for being misinterpreted.
all the informations you have given to me are worthy and its a
great help,i appreciated a lot.i know im new to this language but
i think,its never too late to learn.
Mackmellow
One statement to do all that!?
There is more than one way, and it is certainly more than one statement. The answer would also likely depend on whether you wanted to do it in C or C++. Either way you need to specify your requirements less ambiguously.
Clifford
Mackmellow,
This looks like another homework problem that you are trying to obscure by
rewording it.
You might be better off if, instead of trying to hide that things are
homework, you provided the correct statement of the problem, and
your code and or thinking about how you have started to address the
problem.
We are willing to help you with doing your homework, but this is
not a place to simply post the problem and wait for someone to
provide you with an answer.
Wayne
Under the category of a rough example that provides a basis for discussion, consider the following code:
include <iostream>
include <limits>
using namespace std;
int main() {
int x = 0;
cout << "Enter an integer: ";
cin >> x;
cin.ignore(numeric_limits<int>::max(), '\n');
if (!cin || cin.gcount() != 1)
cout << "Not an integer.\n";
else
cout << "You entered: " << x << "\n";
return 0;
}
Lifted from here:
http://rafb.net/efnet_cpp/faq/io/inputval/
Hey Wayne!
Thanks for your information about the codes but
i just like to know you that all my comments that
has been posted are not homeworks, it is just an
experimental reason for i just love to learn programming.
i already earned my degree in engineering,im not a student anymore
and im now starting to self-study those things.
For further comments on my programming,i expect and hope for
your help and guidelines.
thankszzz....
"i just love to learn programming"
Then that is even worse than if it were homework.
Believe me, very few people learn anything, really learn it,
from looking at someone else's code.
I have seen a number of people try, but beyond a superficial,
"I see how you did that" understanding, they really don't get
it.
How did you get a degree in Engineering without learning C?
What are they pushing as a programming language these days,
Matlab?
Wayne
Hey Wayne!
Seems like you're mad at me buddy!.You're right, very few people
learn anything from looking at someone's code but im not
copying your code all the way,im just getting your idea in order
to apply it in my experimental study in C,im new to this language and has just started to self-study cause im not an IT Prof.I just hope your understanding cause i just need a little help.
i hope im not forcing you to answer my questions cause i want
some help which is heartily given not by your pride,that,if you
would'nt mind.
Could you please give me an idea on object-oriented programming in C++ by giving its algorithm,data structure,and a simple example.
Not mad, but I do think you are misinerpreting what this place is. It
is not a paid help line. You should not feel comfortable posting code,
and simply saying "Correct this". You should not feel comfortable asking
someone to put a lecture together for you, on a topic that a number of
free books and online tools cover.
Specific questions, yes. "Teach me about OO" is something that would
cover several lectures in school and is beyond the scope of what you
should feel comfortable asking complete strangers to do for you for
free.
Now:
In the thread titled "Please Read Before Posting a Question" is a section on
useful links - it has a number of links to free online books and other resources
that can help you in your quest.
Wayne
Now, you can understand what I have told you in terms of understanding this
place, or you can just decide I am so mean old guy who doesn't want to help
you.
Wayne (issomean)
Consider this for context:
http://www.intap.net/~drw/cpp/cpp06_01.htm
To me - my simple minded framework is this - an object is a way of packing together
data, and code for processing that data, as well as interfacing to the rest of the world
into a convenient structure. Think of it as a super type.
You can then create instances of this type - just like you make instances of a type
integer in line of code:
int waynesamoron = 0;
More than that, these types can be used to create other types through inheritance.
Now, how is this all used. Well, to write "Hello World", it probably doesn't do
you much good. On the other hand, if you are writing code in which different
things interact - you can, at times, model those things by objects.
Here is a stupid example of a one file program that creates a class, and then some
instances of that class. Yes, I "borrowed" it from a tutorial...
include <iostream>
using namespace std;
class Stack
{
int stk[100];
int top;
public:
Stack(): top(0) {}
~Stack() {}
void Clear() {top=0;}
void Push(int i) {if (top < 100) stk[top++]=i;}
int Pop()
{
if (top > 0) return stk[--top];
else return 0;
}
int Size() {return top;}
};
int main()
{
Stack stack1, stack2;
}