Tuesday, July 14, 2009

C++ for beginners desperate for answers please help?

I really need your help please answers the questions 5 points for the best answer!





Explain the following bitwise operations in C++


a) and b) or





what is meant by the term zero indexed





what does the address operator do





list the permission values assigned to the number 0,1,2, and 4

C++ for beginners desperate for answers please help?
Q) Explain the following bitwise operations in C++





a)and





For each bit in the source and destination, "and"


results in a "1" only if *both* inputs are "1"





0 %26amp; 0 = 0


0 %26amp; 1 = 0


1 %26amp; 1 = 1


1 %26amp; 0 = 0








b) or





"or" results in a "1" if *either* inputs are "1"





0 | 0 = 0


0 | 1 = 1


1 | 1 = 1


1 | 0 = 1








Q. what is meant by the term zero indexed





It means that the first element of an array


is index "0". Some languages base their arrays


from element 1 (ie. Fortran). Others


allow the first element index to be user


specified (ie. Pascal).





Q. what does the address operator do





It returns the value of the "location" of a variable


in memory. It allows a "pointer" to refer to


a variable (by holding the variable's address).





Q. list the permission values assigned to the


number 0,1,2, and 4





I assume that this is about Unix permissions


which uses bits to specify read "r", write "w"


and execute (x).





0 = 000 ==%26gt; no read, write, or execute permission


1 = 001 ==%26gt; execute only (no read or write)


2 = 010 ==%26gt; write only, no read or exec


4 = 100 ==%26gt; read only, no write or exec
Reply:Ahhh... I'm always a bridesmaid but never a bride.. hehehe.. In any event...





1) BITWISE OPERATIONS:





The bitwise-AND operator ("%26amp;") compares each bit from the first operand to the corresponding bit in the second operand. If both bits are 1, the corresponding resulting bit is 1. Otherwise, the resulting bit is 0.


EXAMPLE:


1011


%26amp; 1101


----------


1001





The bitwise-inclusive-OR operator ("|") compares each bit from the first operand to the corresponding bit in the second operand. If either bit is 1, the corresponding resulting bit is 1. Otherwise, the corresponding resulting bit is 0.


EXAMPLE:


1011


%26amp; 1101


----------


1111





The bitwise-exclusive-OR operator("^") compares each bit of its first operand to the corresponding bit of its second operand. The result in each position is 1 if the two bits are different, and 0 if they are the same.





EXAMPLE:


1011


%26amp; 1101


----------


0110








2. ZERO INDEXED.


When you have an array, the first element is referenced in that array is the "zero" element. This is due to our ecumenically historic approach to numbers... Thanks to an Indian named Pingala and later by the Greeks, "0" (zero) is recognized in our numbering system. So if we count by ten's, the actual numbers are ZERO through 9:





C | X | I (excuse the roman numerals)


----------------


1 2 0





So in the "one's" column, we have "0" or our first non-number, number...


With ALL MY HOT AIR extinguished... here's a C++ reference using the "0" element:





int nMyIntArray[20];





nMyIntArray[0] = 12; // The first array element equals 12.


nMyIntArray[1] = 24; // The second array element equals 24.





I need a drink....





3. ADDRESS-OF OPERATOR.


The address-of operator ("%26amp;") provides the address of a operand. The address-of operator can only be applied to variables with fundamental, structure, class, or union types that are declared at the file-scope level, or to sub-scripted array references.








4. PERMISSION VALUES:


This one, you've got me stumped... Typical permissions implement a scheme with relative numeric definitions applying to the scheme design. So without knowing what system of security you're thinking of, these numbers have no apparent or inherent security rights...


No comments:

Post a Comment