Character Encoding in C
36 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Code should be ______ but not so short that it is cryptic

concise

Identifiers should accurately describe the data being ______

stored

The first letter of each word in camelNotation is capitalized, with the exception of the ______ word

first

Reserved words are used for the ______ own use

<p>language's</p> Signup and view all the answers

C++ reserved words include ______, namespace, and template

<p>asm</p> Signup and view all the answers

Identifiers should avoid using ______ characters

<p>underscore</p> Signup and view all the answers

The contents of this document are copyrighted by ______ and Seneca College

<p>Chris Szalwinski</p> Signup and view all the answers

This document is part of the introduction to ______

<p>C</p> Signup and view all the answers

Since characters and symbols have no intrinsic ______ representation, the host platform provides the collating sequence for associating each character and symbol with a unique integer value.

<p>binary</p> Signup and view all the answers

______ is more popular and represents the letter A by the bit pattern 010000012, that is the hexadecimal value 0x41, that is the decimal value 65.

<p>ASCII</p> Signup and view all the answers

______ and ______ are not compatible.

<p>ASCII; EBCDIC</p> Signup and view all the answers

Neither ______ nor ______ contain enough values to represent most of the characters and symbols in the world languages.

<p>ASCII; EBCDIC</p> Signup and view all the answers

A ______ programming language uses a type system to interpret the bit streams in memory.

<p>typed</p> Signup and view all the answers

The Unicode standard, which is compatible with ______, provides a much more comprehensive collating system.

<p>ASCII</p> Signup and view all the answers

There are three schemes for storing negative integers: ______ notation (most popular), 1's complement notation, and sign magnitude notation.

<p>2's complement</p> Signup and view all the answers

A ______ is the rule that defines how to store values in memory and which operations are admissible on those values.

<p>type</p> Signup and view all the answers

A ______ occupies one byte and can store a small integer value, a single character or a single symbol.

<p>char</p> Signup and view all the answers

An ______ occupies one word and can store an integer value.

<p>int</p> Signup and view all the answers

The four most common types in the C language for performing arithmetic calculations are ______, int, float, and double.

<p>char</p> Signup and view all the answers

This chapter describes the four most common ______ in the C language and the ranges of values that these types allow.

<p>types</p> Signup and view all the answers

After reading this section, you will be able to select appropriate ______ for storing program variables and constants.

<p>types</p> Signup and view all the answers

This chapter concludes by describing how to allocate memory for variables by identifying their contents using a ______.

<p>type</p> Signup and view all the answers

To obtain the 2's complement of an integer, we ______ the bits and add one

<p>flip</p> Signup and view all the answers

The IEEE 754 standard is used for ______ and Floating-Point Arithmetic

<p>Binary</p> Signup and view all the answers

A float has ______ bits, consisting of one sign bit, an 8-bit exponent and a 23-bit significand

<p>32</p> Signup and view all the answers

A double occupies ______ bits, has one sign bit, an 11-bit exponent and a 52-bit significand

<p>64</p> Signup and view all the answers

The number of bits in the significand is limited, so the ______ and double types cannot store all possible floating-point values exactly

<p>float</p> Signup and view all the answers

The number of bytes allocated for a type determines the ______ of values that that type can store

<p>range</p> Signup and view all the answers

Ranges for some types depend on the ______ environment:

<p>execution</p> Signup and view all the answers

The type ______ has a size of 8 bits:

<p>char</p> Signup and view all the answers

The ______ type has a minimum size of 16 bits:

<p>short</p> Signup and view all the answers

The limits on a ______ and double depend on the execution environment:

<p>float</p> Signup and view all the answers

We store program data in ______:

<p>variables</p> Signup and view all the answers

A declaration associates a program ______ with a type:

<p>variable</p> Signup and view all the answers

The type of a variable identifies its ______ properties:

<p>data</p> Signup and view all the answers

The limits on the ______ are in base 10:

<p>exponent</p> Signup and view all the answers

Study Notes

Naming Conventions

  • Use descriptive and concise names that do not require comments to describe their purpose
  • Use "camelNotation" (first letter of each word capitalized except the first word)
  • Avoid underscore characters to avoid conflicts with system libraries

Reserved Words

  • The C language reserves specific words for its own use, including:
    • auto, break, case, char, const, continue, default, do, double, else, enum, extern, float, for, goto, if, inline, int, long, register, return, short, signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile, while
  • Avoid using C++ reserved words, including:
    • asm, bool, catch, class, const_cast, delete, dynamic_cast, explicit, export, false, friend, mutable, namespace, new, operator, private, protected, public, reinterpret_cast, static_cast, template, this, throw, typeid, typename, using, virtual, wchar_t

Introduction to C

  • C is a typed programming language that uses a type system to interpret bit streams in memory
  • A type defines how to store values in memory and which operations are admissible on those values
  • The relation between types and raw memory is illustrated in the figure below

Types

  • Four most common types in C are:
    • char
    • int
    • float
    • double

Arithmetic Types

  • char:
    • Occupies one byte
    • Can store a small integer value, a single character, or a single symbol
  • int:
    • Occupies one word
    • Can store an integer value

Negative Values

  • Three schemes for storing negative integers:
    • 2's complement notation (most popular)
    • 1's complement notation
    • Sign magnitude notation
  • To obtain the 2's complement of an integer:
    • Flip the bits
    • Add one

Floating-Point Data

  • Floating-point types store tiny and huge values by decomposing values into three components:
    • Sign
    • Exponent
    • Significand (or mantissa)
  • IEEE 754 Standard for Binary and Floating-Point Arithmetic is the most popular model
  • float:
    • 32 bits
    • One sign bit, 8-bit exponent, and 23-bit significand (or mantissa)
  • double:
    • 64 bits
    • One sign bit, 11-bit exponent, and 52-bit significand (or mantissa)

Value Ranges

  • The number of bytes allocated for a type determines the range of values that that type can store
  • Ranges for some types depend on the execution environment
  • Integral types:
    • char: -128 to 127 or 0 to 255
    • short: -32,768 to 32,767
    • int: -32,768 to 32,767 (2 bytes) or -2,147,483,648 to 2,147,483,647 (4 bytes)
    • long: -2,147,483,648 to 2,147,483,647 (4 bytes) or -9,233,372,036,854,775,808 to 9,233,372,036,854,775,807 (8 bytes)
  • Floating-point types:
    • float: depends on the execution environment
    • double: depends on the execution environment

Variable Declarations

  • A declaration associates a program variable with a type
  • The type identifies the properties of the variable

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Description

This quiz explores how C language associates characters and symbols with unique integer values using collating sequences such as ASCII and EBCDIC.

More Like This

Character Encoding Quiz
32 questions

Character Encoding Quiz

SophisticatedProtagonist avatar
SophisticatedProtagonist
Computer Character Encoding
18 questions

Computer Character Encoding

ExtraordinaryLaboradite avatar
ExtraordinaryLaboradite
Understanding Random Character Codes
5 questions
Use Quizgecko on...
Browser
Browser