BrainDump
  Home arrow BrainDump arrow Page 2 - 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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Moblin 
JMSL Numerical Library 
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 / 13
    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 - Variables


    (Page 2 of 4 )

    Variables are objects used to store data. The easiest way to think of a variable is like a box that holds a book. You can store a book in the box, take the book out and read it, modify the book and put it back, replace the book with an entirely new book, or take it out and leave the box empty for later use. The data in a variable is just that, variable. We worked with variables in the above example to store data from the scanf_s() function.

    All variables in C must be assigned a data type (you must tell the program what type of data the variable will hold). Before we can use a variable, we must declare it. We do so like this:


    int my_number;

    This basically tells the system, "hey, I am going to need space for a variable named my_number."

    You can also declare more than one variable on a line:


    int my_number, yournumber, yomamasnumber;

    And lastly, we can assign a value to a variable at the same time we declare it:


    int my_number =22;

    This stores the value 22 in the variable named my_number.

    If we wanted to store a variable in another variable, we could do that also:


    my_number = yournumber;

    And if you want to get weird, you can assign multiple variables the same value like so:


    my_number = yournumber = yomamanumber = 1900;

    Naming Conventions

    Variable names can consist of letters (both upper and lowercase), numbers, and the underscore(_). They cannot begin with a number. Here are some sample names for your perusal:


    • employees

    • employee_number

    • employeeNumber

    • _employees

    • Boss

    • BoSs

    • hero1902

    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

    - Microsoft Office SharePoint Server
    - Microsoft Office SharePoint Designer
    - Microsoft Windows SharePoint Services 3.0
    - Microsoft Live Mesh Overview
    - XAML Brushes and Silverlight
    - Silverlight and XAML Basics
    - Immortal XP
    - XAML Basics
    - Microsoft Surface
    - Making Your First Active X Control in Visual...
    - 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





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