Home Contents



/* Program: Lab2_2.c */
/* Does various calculations involving a float x. */
/* Francis O'Donovan 14-11-97 */

#include <stdio.h>

main()
{

        printf( "Lab2_2.c\n\n" );
        printf( "Does various calculations involving a float x.\n\n" );
        printf( "Francis O'Donovan 14-11-97\n\n\n" );

/* (a) */

        float x = 10.5097;

/* (b) */

        printf( "The value of the float x is currently %.4f.\n", x) ;

/* (c) */

        x++ ;

/* (d) */

        printf( "The value of the float x is currently %.4f.\n", x) ;

/* (e) */

        x = x/2 ;

/* (f) */

       printf( "The value of the float x is currently %.4f.\n", x) ;

/* (g) */

        /* First extra time */

        x++ ;
        printf( "The value of the float x is currently %.4f.\n", x) ;
        x = x/2 ;
        printf( "The value of the float x is currently %.4f.\n", x) ;

        /* Second extra time */

        x++ ;
        printf( "The value of the float x is currently %.4f.\n", x) ;
        x = x/2 ;
        printf( "The value of the float x is currently %.4f.\n", x) ;

        /* Third extra time */

        x++ ;
        printf( "The value of the float x is currently %.4f.\n", x) ;
        x = x/2 ;
        printf( "The value of the float x is currently %.4f.\n", x) ;

        /* Fourth extra time */

        x++ ;
        printf( "The value of the float x is currently %.4f.\n", x) ;
        x = x/2 ;
        printf( "The value of the float x is currently %.4f.\n", x) ;

}


Home Contents



© Francis O'Donovan 1999.