Click here to Skip to main content
15,922,584 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: operator != for iterators Pin
Dave Bryant30-Sep-03 14:52
Dave Bryant30-Sep-03 14:52 
GeneralRe: operator != for iterators Pin
mcoloney30-Sep-03 14:58
mcoloney30-Sep-03 14:58 
GeneralRe: operator != for iterators Pin
Dave Bryant30-Sep-03 15:02
Dave Bryant30-Sep-03 15:02 
GeneralRe: operator != for iterators Pin
mcoloney30-Sep-03 15:07
mcoloney30-Sep-03 15:07 
GeneralCode to show Sample Unicode Chars Pin
prpub130-Sep-03 14:29
sussprpub130-Sep-03 14:29 
GeneralThe for statement Pin
claytide30-Sep-03 11:50
claytide30-Sep-03 11:50 
GeneralRe: The for statement Pin
Christian Graus30-Sep-03 12:07
protectorChristian Graus30-Sep-03 12:07 
GeneralRe: The for statement Pin
Colin Angus Mackay30-Sep-03 12:36
Colin Angus Mackay30-Sep-03 12:36 
It's been a couple of years since I've done C++ but here goes:

a^b : ^ is a bitwise Exclusive-OR operator, e.g. 1^1=0; 1^2=3; 2^2=0; 32^64=96; 32^96=64;
Bitwise Exclusive OR Operator: ^[^]

c%2 : % is a modulus operator
C Multiplicative Operators[^]

>>= is a right-shift assignment operator
Shift Operators: >> and <<[^]

for
C++ language reference: The for statement[^]

c is initialised to a XOR b
cnt is initialised to zero.

The iteration will continue to loop around so long as c is greater than zero. This test is done at the start of each iteration.

At the end of each iteration cycle cnt is set to the remainder of c divided by 2 (In other words cnt will be 1 if c is odd, or zero if c is even) and c is shifted one bit to the right (in other words divided by two)

Now, while I was writing this, it occurred to me that this is an interview style question. No one in their right mind would code this.

So, for a bonus, (assuming c is an unsigned int and the code inside the loop doesn't alter c), what is the maximum number of iterations possible?




--Colin Mackay--

"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)


GeneralRe: The for statement Pin
Blake Coverett30-Sep-03 19:16
Blake Coverett30-Sep-03 19:16 
GeneralSimulating clicks.. Pin
Anonymous30-Sep-03 11:28
Anonymous30-Sep-03 11:28 
GeneralRe: Simulating clicks.. Pin
Ravi Bhavnani30-Sep-03 12:19
professionalRavi Bhavnani30-Sep-03 12:19 
GeneralRAPI Pin
Anthony988730-Sep-03 10:09
Anthony988730-Sep-03 10:09 
GeneralRe: RAPI Pin
Jonas Larsson30-Sep-03 23:29
Jonas Larsson30-Sep-03 23:29 
GeneralBitConverter Pin
Arbage30-Sep-03 9:36
Arbage30-Sep-03 9:36 
GeneralRe: BitConverter Pin
Joaquín M López Muñoz30-Sep-03 10:18
Joaquín M López Muñoz30-Sep-03 10:18 
GeneralScrollbar Pin
Anonymous30-Sep-03 8:41
Anonymous30-Sep-03 8:41 
GeneralRe: Scrollbar Pin
Maximilien30-Sep-03 9:22
Maximilien30-Sep-03 9:22 
GeneralRe: Scrollbar Pin
Anonymous1-Oct-03 7:31
Anonymous1-Oct-03 7:31 
GeneralDialog background color Pin
Jahangir Jamshed30-Sep-03 7:23
sussJahangir Jamshed30-Sep-03 7:23 
GeneralRe: Dialog background color Pin
Jahangir Jamshed30-Sep-03 18:10
sussJahangir Jamshed30-Sep-03 18:10 
GeneralRegistry Problem Pin
Anonymous30-Sep-03 6:22
Anonymous30-Sep-03 6:22 
GeneralRe: Registry Problem Pin
David Crow30-Sep-03 7:42
David Crow30-Sep-03 7:42 
GeneralRe: Registry Problem Pin
Michael Dunn30-Sep-03 12:00
sitebuilderMichael Dunn30-Sep-03 12:00 
Generalstring question.. Pin
RobJones30-Sep-03 5:24
RobJones30-Sep-03 5:24 
GeneralRe: string question.. Pin
David Crow30-Sep-03 5:26
David Crow30-Sep-03 5:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.