[cs13001] cs13001 Digest, Vol 7, Issue 2

Wassem, Rylan rwassem at kent.edu
Tue Feb 5 12:03:27 EST 2013


This is funny:

http://www.youtube.com/watch?v=x1TsOHyJPpw&list=PLCC678UChy0L6Z9XMnj0Gu9k-9Utoo1sB&index=14


-----Original Message-----
From: cs13001-bounces at cs.kent.edu [mailto:cs13001-bounces at cs.kent.edu] On Behalf Of cs13001-request at cs.kent.edu
Sent: Tuesday, February 05, 2013 12:00 PM
To: cs13001 at cs.kent.edu
Subject: cs13001 Digest, Vol 7, Issue 2

Send cs13001 mailing list submissions to
	cs13001 at listmail.cs.kent.edu

To subscribe or unsubscribe via the World Wide Web, visit
	https://listmail.cs.kent.edu/mailman/listinfo/cs13001
or, via email, send a message with subject or body 'help' to
	cs13001-request at listmail.cs.kent.edu

You can reach the person managing the list at
	cs13001-owner at listmail.cs.kent.edu

When replying, please edit your Subject line so it is more specific than "Re: Contents of cs13001 digest..."


Today's Topics:

   1. on increment and decrement (Mikhail Nesterenko)
   2. Re: Question (Mikhail Nesterenko)
   3. Re: Question (Mikhail Nesterenko)


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

Message: 1
Date: Mon, 4 Feb 2013 12:46:11 -0500
From: Mikhail Nesterenko <mikhail at cs.kent.edu>
Subject: [cs13001] on increment and decrement
To: Computer Science I <cs13001 at cs.kent.edu>
Message-ID: <20130204174611.GA10159 at cs.kent.edu>
Content-Type: text/plain; charset=us-ascii

CSI students,

There was a discussion on increment and decrement operations in one of the classes. Several clarifications.

* Increment and decrement operations can only apply to a variable. The
  precise term for it is "l-value": something that has an explicit
  address in memory (whose value can be decremented or incremented).

  Expressions are not l-values. Therefore, operations like this:

	a =(b+5)++; 

  are not allowed. Microsoft's compiler generates error:

        '++' needs l-value

  Moreover, 
	a = (b++)++;

  is also not allowed (the increment in parentheses is considered an
  expression).

  However, this expression is perfectly legal:

	a = b++ + ++c;   // "b" and "c" are incremented, their values are
	  	         // summed and assigned to "a"
			 // note old c's value is used in the expression	
   
* In modern programming, the suffix form of the increment/decrement is
  considered inefficient and is to be avoided. The reason is
  this. Consider the statement below

      a = b++ - 33 + (a*c-33);

  Variable "b" is incremented using the suffix form. This means that
  the old value of "b" is used in the expression. When compiler
  generates object code, it has to create a temporary variable to
  store the old value (either to be used in the expression or to be
  assigned to the variable). This inefficiency may be minor for
  the types with have studied so far. However, it may be significant
  for the classes/objects that we will study later.

  Note that there is no need for temporary variables, and no resultant
  inefficiency in case the prefix from of the increment is used:

      a = ++b - 33 + (a*c-33);


Thanks,
--
Mikhail


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

Message: 2
Date: Mon, 4 Feb 2013 22:19:08 -0500
From: Mikhail Nesterenko <mikhail at cs.kent.edu>
Subject: Re: [cs13001] Question
To: Computer Science I <cs13001 at cs.kent.edu>
Message-ID: <20130205031908.GB24075 at cs.kent.edu>
Content-Type: text/plain; charset=us-ascii


> 
> I noticed after you input something in a program it pops up and closes the
> console window.  Is there a way to keep the window open until you hit enter
> and if so what is the code you would write for that?
> 

The recommended way to do it is to create a breakpoint on the last
line of your program. See information on breakpoints on the lab's website:

  http://www.cs.kent.edu/~mikhail/classes/csi.s13/Labs/MSVS/debugging.html

Or just right-click on the last line and select "run to cursor".

Thanks,
--
Mikhail


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

Message: 3
Date: Mon, 4 Feb 2013 23:01:07 -0500
From: Mikhail Nesterenko <mikhail at cs.kent.edu>
Subject: Re: [cs13001] Question
To: Computer Science I <cs13001 at cs.kent.edu>
Message-ID: <20130205040107.GA25576 at cs.kent.edu>
Content-Type: text/plain; charset=us-ascii

Mikhail Nesterenko wrote:
> 
> > 
> > I noticed after you input something in a program it pops up and closes the
> > console window.  Is there a way to keep the window open until you hit enter
> > and if so what is the code you would write for that?
> > 
> 
> The recommended way to do it is to create a breakpoint on the last
> line of your program. See information on breakpoints on the lab's website:
> 
>   http://www.cs.kent.edu/~mikhail/classes/csi.s13/Labs/MSVS/debugging.html
> 
> Or just right-click on the last line and select "run to cursor".
> 

One of the students just pointed out that there is an even more
straightforward way of suspending the program before the last line is
executed.

Press Ctrl+F5 to run the program.

Thanks,
--
Mikhail


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

_______________________________________________
cs13001 mailing list
cs13001 at listmail.cs.kent.edu
https://listmail.cs.kent.edu/mailman/listinfo/cs13001


End of cs13001 Digest, Vol 7, Issue 2
*************************************





More information about the cs13001 mailing list