User Tools

Site Tools


haas:fall2011:unix:project:datatypes

Project: DATA TYPES IN C

A project for CSCS1730 UNIX/Linux Fundamentals by YOUR NAME OR GROUPMEMBER NAMES during the SEMESTER YEAR.

This project was begun on DATE and is anticipated to take X AMOUNT OF TIME. (Upon completion you can correct this with the actual length).

Objectives

To better understand the types, ranges, and quantities of the various whole number data types in the C programming language.

Prerequisites

In order to successfully accomplish/perform this project, the listed resources/experiences need to be consulted/achieved:

  • ability to edit a text file in vi
  • know how to compile C programs with gcc

Background

State the idea or purpose of the project. What are you attempting to pursue?

Upon approval, you'll want to fill this section out with more detailed background information. DO NOT JUST PROVIDE A LINK.

Providing any links to original source material, such as from a project page, is a good idea.

You'll want to give a general overview of what is going to be accomplished (for example, if your project is about installing a web server, do a little write-up on web servers. What is it, why do we need one, how does it work, etc.)

Scope

Knowing the bounds and behaviors of the various data types empowers developers to better utilize the programming resources available to them.

Your task is to take the following program:

#include <stdio.h>
 
int main()
{
    unsigned short int val1;
    signed short int val2;
 
    val1 = 0;
    val2 = 0;
 
    printf("val1 before: %hu, it occupies %d bytes\n", val1, sizeof(val1));
    printf("val2 before: %hd, it occupies %d bytes\n", val2, sizeof(val2));
 
    val1 = val1 - 1;
    val2 = val2 - 1;
 
    printf("val1 after: %hu\n", val1);
    printf("val2 after: %hd\n", val2);
 
    return(0);
}

And determine the size, range, and quantity for each of the following data types:

  • unsigned char
  • signed char
  • unsigned short int
  • signed short int
  • unsigned int
  • signed int
  • unsigned long int
  • signed long int
  • unsigned long long int
  • signed long long int

Attributes

State and justify the attributes you'd like to receive upon successful approval and completion of this project.

  • The UNIX development environment: playing with C
  • Text Processing: editing syntax in vi
  • commands: using the compiler
  • files & directories: recognizing where you source file is, and how that is different from the executable

Procedure

The actual steps taken to accomplish the project. Include images, code snippets, command-line excerpts; whatever is useful for intuitively communicating important information for accomplishing the project.

Code

Upon completion of the project, if there is an applicable collection of created code, place a copy of your finished code within <code> </code> blocks here.

/*
 * hello.c - A sample "Hello, World!" program
 * 
 * written by NAME for COURSE on DATE
 *
 * compile with:
 *   gcc -o hello hello.c
 *
 * execute with:
 *   ./hello
 */
 
#include <stdio.h>
 
int main()
{
    printf("Hello, World!\n");    // Output message to STDOUT
    return(0);
}

Execution

Again, if there is associated code with the project, and you haven't already indicated how to run it, provide a sample run of your code:

lab46:~/src/cprog$ ./hello
Hello, World!
lab46:~/src/cprog$ 

Reflection

Comments/thoughts generated through performing the project, observations made, analysis rendered, conclusions wrought. What did you learn from doing this project?

References

In performing this project, the following resources were referenced:

  • URL1
  • URL2
  • URL3 (provides useful information on topic)
  • URL4

Generally, state where you got informative and useful information to help you accomplish this project when you originally worked on it (from Google, other wiki documents on the Lab46 wiki, etc.)

haas/fall2011/unix/project/datatypes.txt · Last modified: 2011/10/27 15:42 by 127.0.0.1