Hey guys, I was reading the C++ Primer book, and I just got to Chapter 2, and I'm confused. . The beginning of the Chapter where it's talking about integral types, bytes, integers, etc. is really confusing. Like, I understand that different types store different information, but one of the practice questions asks what the range of integers are allowed in a 8 bit short type. What....?
Hmm, maybe I'm too dumb to get into this . But no, I'm not giving up. If any of you can give me an explanation or a URL to an article or something talking about this in a clearer way, please do so, and thanks.
Also, one of the exercises in the book asks you to write a program to let the user input a series of numbers, and then print out how many negative numbers were put in. I tried this, and all I could manage was for it to print out the value of the negative number, but not how many negative numbers there are. Could someone help me with this please? Since my computer that I write code on is different from this computer, I can't be sure that this is the code I wrote, but I think this is it.
How do I do this..?Code:#include <iostream> using namespace std; int main() { cout << "Enter a series of numbers: " << endl; int value; cin >> value; while (value <= 0) cout << value << endl; cin.ignore(cin.rdbuf()->in_avail()+1); return 0; }
-Many thanks, Kai.