Name: __________________________

 

Lab 3 printf and sizeof

 

As we’ve learned in class, in C the size of data types are not exactly defined.  In this lab, you will write a program that displays the size of the various data types.

 

Using the sizeof() keyword, determine the size of the following data types:

 

int

short

long

long long

unsigned int

char

float

double

long double

 

Have the output be displayed to the screen in the following tabular (use tabs to align the column of sizes) format:

 

int     4 bytes

      .

      .

      .

 

When you are done, we can use another feature of the UNIX shell to submit the output. Text that is displayed to the screen in UNIX can be capture into a file using the > (redirection) command.

 

Run your program like (assuming you named the output file “lab3”):

 

./lab3 > lab3.txt

 

And now the file lab3.txt will contain the output, and the screen will be empty. You can open lab3.txt in pico to check the output.

 

Take this file and your source file and email it to the TA (mehmud@cs.pitt.edu)

 

Hints: