CSC231 Mystery C Program Solution

From dftwiki3
Revision as of 12:22, 13 November 2014 by Thiebaut (talk | contribs)
Jump to: navigation, search

--D. Thiebaut 14:10, 8 October 2010 (UTC)




/* 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 );
}