CSC231 Mystery C Program Solution

From dftwiki3
Revision as of 11:20, 24 September 2008 by Thiebaut (talk | contribs) (New page: Back to Weekly Schedule ---- <code><pre> /* mystery.cpp // D. T. // mystery program // To compile and run this program: // // g++ mystery.cpp // a.out //...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Back to Weekly Schedule


/* mystery.cpp
// D. T.
// mystery program
// To compile and run this program:
//
//     g++ mystery.cpp
//     a.out
//
// The output of the program is the following
//
// 32740
// -32756
//
// With what positive values were x and y initialized
// at the beginning of the program.  Explain why.
// (a short int contains 16 bits)
*/

#include <stdio.h>

main() {

    short int x = 32700 ;
    short int y = 40 ;

    x = x+y;
    printf( "%d\n", x );

    x = x+y;
    printf( "%d\n", x );
}