Docsity

Data Representation Workshop in CSC 8400 Computer Organization - Prof. Thomas Way, Assignments of Operating Systems

Toggle sidebar
bg1
CSC 8400 Computer Organization 1 Workshop 1
CSC 7100 Computer Systems Summer 2007
Workshop 2: Data Representation
Dr. Tom Way
June 11, 2007
Due: June 18, 2007
Worth: 50 points
This workshop is designed to increase your understanding of data representation and
basic input and output in a C program.
Description
You are to write a C program that prints an integer and a floating point value in different
eight ways by re-interpreting it as the following data types or output formats:
• char
• hexadecimal
• scientific notation
• int
• unsigned int
• long
• long long
• float
You should compile and run your program with a variety of different values. Base your
program on the example below.
Resources
• “man” page for printf
• other online C programming references
• see class web site “Reources” page
What to hand in
Email me with the name of your program file and I will retrieve it from your account,
compile it and run it. In the email provide a brief explanation of what you observed.
Grading criteria
Program compiles and runs 25
Accepts numeric input 5
Rejects non-numeric input 5
Prints output in 8 formats 5
Brief explanation of observations 10
pf2

Partial preview of the text

Download Data Representation Workshop in CSC 8400 Computer Organization - Prof. Thomas Way and more Assignments Operating Systems in PDF only on Docsity!

CSC 8400 Computer Organization 1 Workshop 1

CSC 7100 Computer Systems Summer 2007

Workshop 2: Data Representation

Dr. Tom Way June 11, 2007

Due: June 18, 2007 Worth: 50 points

This workshop is designed to increase your understanding of data representation and basic input and output in a C program.

Description

You are to write a C program that prints an integer and a floating point value in different eight ways by re-interpreting it as the following data types or output formats:

  • char
  • hexadecimal
  • scientific notation
  • int
  • unsigned int
  • long
  • long long
  • float

You should compile and run your program with a variety of different values. Base your program on the example below.

Resources

  • “man” page for printf
  • other online C programming references
  • see class web site “Reources” page

What to hand in

Email me with the name of your program file and I will retrieve it from your account, compile it and run it. In the email provide a brief explanation of what you observed.

Grading criteria

Program compiles and runs 25 Accepts numeric input 5 Rejects non-numeric input 5 Prints output in 8 formats 5 Brief explanation of observations 10

CSC 8400 Computer Organization 2 Workshop 1

/------------------------------------------------------- Example program -------------------------------------------------------/

#include <stdio.h>

int main() { int int_value = 65; double float_value = -67.5; // Print int_value as various types // -------------------------------- printf("original int_value is %d\n", int_value); // as char // as hexadecimal // as scientific notation // as int // as unsigned int // long // as long long // as float printf("int_value as float: %f\n", int_value); // Print float_value as various types // ---------------------------------- printf("original float_value is %f\n", float_value); // as char // as hexadecimal // as scientific notation // as int printf("float_value as int: %d\n", float_value); // as unsigned int // long // as long long // as float }