/* Program: Lab2_4.c */
/* Does various calculations involving a char
y and a float x, which the user inputs. */
/* Francis O'Donovan 14-11-97 */
#include <stdio.h>
main()
{
printf( "Lab2_4.c\n\n" );
printf(
"Does various calculations involving a char y and a float
x, which the user inputs.\n\n" );
printf(
"Francis O'Donovan 14-11-97\n\n\n" );
/* (a) */
char y;
float
x;
printf( "Please type in a char: " );
y =
getchar();
x = y;
/* (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)
;
}
© Francis O'Donovan
1999.