BrainDump
  Home arrow BrainDump arrow Page 2 - C Statements
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 
Mobile Linux 
App Generation ROI 
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 Statements
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 21
    2008-02-25

    Table of Contents:
  • C Statements
  • ELSE!
  • Else...If
  • The Case Statement

  • 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 Statements - ELSE!


    (Page 2 of 4 )


    #include <stdio.h>

    #include <stdlib.h>

    void main()

    {

    int yourmom;

    int mymom;

    printf("Enter your mother's weight: ");

    scanf_s("%i",&yourmom);

    printf("Enter my mother's weight: ");

    scanf_s("%i",&mymom);

    if(yourmom>mymom)

    {

    printf("nnnnYep...yer mom is a big fat pig.nnnnn");

    }

    else

    {

    printf("nnMy mother may be fatter...but yours is still uglyn");

    }

    }

    This program works off of our good buddy the Else clause. Using else allows us to say: If this occurs do that, else do that. The above program works exactly as our previous program, only now if my mother is fatter than yours, it prints:

      My mother may be fatter...but yours is still ugly

    And of course if your mother had been fatter, it would have printed:

      Yep...yer mom is a big fat pig.

    Lastly, if neither condition had been true (ie; if the two values had been equal to one another), nothing would have occurred. Well never fear...we have a fix for that as well.

    More BrainDump Articles
    More By James Payne


       · Hey, thanks for dropping by for the continuing discussion on C. In this article we...
     

    BRAINDUMP ARTICLES

    - Internet Explorer 8 Review
    - Nilpo`s Top Windows Add-Ons
    - Beginning Silverlight 2.0 Development using ...
    - Fixing Vista`s Troubles
    - Preparing Windows Images for Mass Deployment
    - The Trouble With Vista
    - Slipstreamed and Unattended Windows Installa...
    - 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





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