BrainDump
  Home arrow BrainDump arrow C: More Operators and Arrays
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: More Operators and Arrays
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-02-19

    Table of Contents:
  • C: More Operators and Arrays
  • Bitwise Operators
  • Arrays
  • Two-Dimensional Arrays
  • Commenting on Your Code

  • 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: More Operators and Arrays


    (Page 1 of 5 )

    In our last article we left off discussing some of C's Operators and how to use them. We will pick up on the same subject in this article, and cover arrays as well. As always, there is a lot to cover, so let's get to it.

    Conditional OR Ternary Operator

    Our good buddy the conditional operator is made up of two symbols: the question mark (?) and the colon(:). Consider the following:

      mine = 100;

      yours = 200;

      ours = (mine > yours) ? mine : yours

    In this example, the variable ours will be assigned the value of the variable yours, or 200. This occurs because the expression (mine > yours) is false. Had it been true, then the value of ours would have been the value of the variable mine, or 100.

    Here is an example:


    #include <stdio.h>

    #include <stdlib.h>


    void main()

    {

    int mine,yours,bigger;

    printf ("Input my number and your number : ");

    scanf_s("%d %d",&mine, &yours);

    bigger = mine > yours ? mine : yours;

    printf("The largest of two numbers is %d \n", bigger);

    }

    This code asks the user for two numbers. It stores the first number in the variable mine, and the second in the variable yours. Next it asks if mine is greater than yours. If so, bigger will get the value of the mine variable. If not, it will get the value of the yours variable. Finally it prints some text and appends the value of the variable bigger.

    If the user had entered the numbers 20 and 50, the result would be:

      Input my number and your number: 20 50

      The largest of the two numbers is 50

    More BrainDump Articles
    More By James Payne


       · Thanks for dropping by to read my article on C Operators and Arrays. In this episode...
     

    BRAINDUMP ARTICLES

    - Firefox on Windows Mobile
    - Microsoft`s Sneaky Firefox Add-On Installati...
    - Microsoft`s Answer to Google Search - Bing
    - Doing Statistical Analysis with MS Excel
    - Extracting Google-Indexed Web Site Pages Usi...
    - Advanced String Manipulation Using MS Excel
    - Using Goal Seek and Solver in MS Excel
    - Internet Explorer 8: A Hands-on View
    - Tools for Beginning Game Developers
    - XAMPP: Tips for Running an Apache/MySQL Serv...
    - Improving Your Visual Studio Workspace
    - A Look at Microsoft`s Mobile Operating System
    - Microsoft Internet Explorer 8: Mixed Reactio...
    - Configuring WSUS 3.0 on Windows Server 2008
    - Migrating to Windows Server 2008





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