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  
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 Statements
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 29
    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

    - 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 5 Hosted by Hostway
    Stay green...Green IT