This is a discussion on my professior gave us an example program for a fiter.. but I can't get it to work... within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Elysia Code: sum = sum + points [i]; mean = sum / datapts; Now, what the heck ...
3. Evaluate !(1 && !(0 || 1)).
A. True
I don't understand why this is true......can someone please break it down and explain it to me? thanks
~Cess~
AKA : total newbie
....and totally frustrated
thanks for any help given.....
I feel like I"m going to fail this class....blah!
1 = true,
0 = false
==> !(true && !(false || true))
==> !(true && !(true))
==> !(true && false)
==> !(false)
==> true
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
!(1 && !(0 || 1)).
Remimber your order of operations.
( 0 || 1 ) = 1
! (1 && !(1))
! (1 && 0)
! (0)
1
Try to help all less knowledgeable than yourself, within
the limits provided by time, complexity and tolerance.
- Nor
Oh ok ya so even though "that OR will be evaluated after AND. " you have to still follow order of operations 1st! ok that makes sense. thank you!
(0||1) = true
!(0||1) =false
1 && 0 = false
! ( 1 && 0) = true
~Cess~
AKA : total newbie
....and totally frustrated
thanks for any help given.....
I feel like I"m going to fail this class....blah!
Ok still going over the C++ tutorial on lesson 3
Code:#include <iostream> using namespace std; // So the program can see cout and endl int main() { // The loop goes while x < 10, and x increases by one every loop for ( int x = 0; x < 10; x++ ) { // Keep in mind that the loop condition checks // the conditional statement before it loops again. // consequently, when x equals 10 the loop breaks. // x is updated before the condition is checked. cout<< x <<endl; } cin.get(); }
What does the cin.get(); do? It doesn't explain it as far as I can see and when I used it in code blocks I didn't notice anything different then when I didn't use it.
Last edited by Cess; 10-23-2011 at 11:02 AM.
~Cess~
AKA : total newbie
....and totally frustrated
thanks for any help given.....
I feel like I"m going to fail this class....blah!
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
what does str[i] = str[i] - 'a' + 'A'; mean in the code below
thanks I have an exam at 1pm so any help would be great... I have to write 2 programs with prototypes in a hour so ya thanks.Code:#include <iostream> using namespace std; int main() { cout << "Enter a character string: "; char str[20]; cin >> str; for (int i=0; str[i]; i++) { if ((str[i] >= 'a')&& (str[i] <= 'z')) str[i] = str[i] - 'a' + 'A'; else { if ((str[i] >= 'A')&& (str[i] <= 'Z')) str[i] = str[i] + 'a' - 'A'; } } cout << str << endl; return 0; }
~Cess~
AKA : total newbie
....and totally frustrated
thanks for any help given.....
I feel like I"m going to fail this class....blah!
Characters are basically integers with limited ranges (0-255 for an 8-bit unsigned char as an example). You can therefore perform arithmetic on char data types of the sort you are seeing here. Imaging for a moment that str[i] contains the letter 'b'. Subtracting 'a' from 'b' results in a difference of 1. If we then add 'A' and 1 together what do you think the result is?
I used to be an adventurer like you... then I took an arrow to the knee.
Chars are stored as single bytes. A single 8-bit byte has 256 possibilities; ie, a numerical value from 0-255 (unsigned) or -128 to 127 signed. These correspond to the ASCII table:
Ascii Table - ASCII character codes and html, octal, hex and decimal chart conversion
So if you subtract 'a' (97) from a lowercase ASCII letter and then add 'A' (65) to it, it will be capitalized.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge