BrainDump
  Home arrow BrainDump arrow Page 3 - C: Input, Variables, and Data Types
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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 / 31
    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
     
     
    ADVERTISEMENT


    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

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek