Practice2 - Datarepresentationinsidethe computer...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
    Data representation inside the  computer Bit – a binary digit: 0 or 1. Bits are always grouped! Byte – a group of 8 bits.  Therefore, a byte can represent up to 2 8 =256 values. The values can range from 0 to 255 or from -128 to 127. The fundamental data unit of a computer. Word – a group of (usually) 4 (or 8) bytes.  4 bytes = 32 bits. Value range: 0 to 2 32  -1    (4,294,967,295 ). Or, more often: -2 31  to 2 31 -1 (-2,147,483,648 to +2,147,483,647).
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
    Inside the computer The computer memory is composed of a long list of  bits. Bits are grouped into bytes and words. Every byte is numbered sequentially. This number is called an address.
Background image of page 2
    What are variables? A named area in the computer memory,  intended to contain values of a certain kind  (integers, real numbers, etc.) They contain the data your program works  with. They can be used to store data to be used  elsewhere in the program. In short – they are the only way to manipulate  data.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
    Example /* Get a length in cm and convert to inches */ #include  <stdio.h> int  main( void ) { double  cm, inches; printf("Please enter length in centimeters: "); scanf("%lf",&cm); inches = cm / 2.54; printf("This is equal to %g inches\n", inches); return  0;
Background image of page 4
    Declaring variables in C Before using a variable, one must  declare it. The declaration first introduces the  variable type, then its name. Optionally, you can set some  characteristics called qualifiers. When a variable is declared, its value is  undefined.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
    Example Variable  Declarations int  i; char  c; float  f1, f2; float  f1=7.0, f2 = 5.2; unsigned   int  ui = 0;
Background image of page 6
  Variable naming rules Letters, digits, underscores i CSE_5a a_very_long_name_that_isnt_very_useful fahrenheit First character cannot be a digit 5a_CSE is not valid! Case sensitive
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/10/2010 for the course CS 463 taught by Professor Can'tsay during the Spring '09 term at Haaga - Helia University of Applied Sciences.

Page1 / 34

Practice2 - Datarepresentationinsidethe computer...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online