BrainDump
  Home arrow BrainDump arrow Page 3 - C: Input, Variables, and Data Types
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

C: Input, Variables, and Data Types
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2008-02-04

    Table of Contents:
  • C: Input, Variables, and Data Types
  • Variables
  • Data Types
  • Data Type Modifiers

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    IBM developerWorks
     
    ADVERTISEMENT

    AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th -1:00PM EST. Register Today!

    C: Input, Variables, and Data Types - Data Types


    (Page 3 of 4 )

    There are four basic data types in C. They are Int, Char, Float, and Double.

    Data Type: Int

    This data type is used to store integers (whole numbers). They are usually 32 bits, though at this point I wouldn't concern myself with that. Variables of this type can hold values ranging from -2147483648 to 2147483647. Here is an example of how you would declare an int variable and store data in it:


    int weight = 320;

    Data Type: Char

    This data type stores a single letter, number, or special character. You can also use the ASCII character set, but again, we won't be discussing that here; just know for now that the option is available. Here is a sample of a program using a char variable:


    #include <stdio.h>

     

    int main ()

    {

    char lyric1;

    char lyric2;

    char lyric3;

    lyric1 = 'A';

    lyric2 = 'B';

    lyric3 = 'C';

     

    printf("It's easy as %c%c%c ", lyric1,lyric2,lyric3);

     

    return(0);

    }

    Data Type: Float

    This data type is used for floating point values. To work, float literals must have a suffix of either f or F, as in: 3.26852f or 2.0F. Note that the float only stores single-precision floating point numbers.

    Data Type: Double

    This data type is very similar to the float, except that it allows you to store double-precision floating point numbers. It takes up 8 bytes typically and does not require the f or F as a suffix: 9.1298273646552717, 2.0, 3.098e+23 are all valid. If you use a number without a decimal, it will be interpreted as an int instead.

    More BrainDump Articles
    More By James Payne


       · Hey, thanks for stopping by. In this article we talk about C and all the glorious...
     

    BRAINDUMP ARTICLES

    - Codes and Packages in Microsoft Project 2007
    - Windows 7: Rumors and Demos
    - XP SP3 Why Me?
    - Breaking Up Your Work in Microsoft Project
    - Breaking Work into Task-Sized Chunks
    - Putting Microsoft`s Worldwide Telescope Unde...
    - Handling Multiple Contracts with Indigo
    - Cleaning Out Your Data in XP
    - Multiple Service Contracts and Indigo
    - Cleaning Out Your Programs in XP
    - Handling Metadata with Indigo
    - Building Blocks for a WCF Service Web Site
    - Help! I Need Some Remote Assistance
    - Using Service Templates with Indigo
    - Windows XP Tips for Task Manager

    Click Here




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway