Home Contents



/* Program: Lab2_3.c */
/* Does various calculations involving a float x, which the user inputs. */
/* Francis O'Donovan 14-11-97 */

#include <stdio.h>

main()
{

        printf( "Lab2_3.c\n\n" );
        printf( "Does various calculations involving a float x, which the user inputs.\n\n" );
        printf( "Francis O'Donovan 14-11-97\n\n\n" );

/* (a) */

        float x;

        printf( "Please type in a float: " );
        scanf( "%f", &x) ;

/* (b) */

        printf( "\nThe 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.