Thread: Why is it that my program does not print for case 1?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    Quote Originally Posted by tabstop View Post
    Ha! That will (okay, should) teach me to read the code and not the question.
    lol. Do you know about the break statement Jasper?

  2. #2
    Registered User
    Join Date
    Apr 2009
    Posts
    41
    I think the problem was to illustrate the out of order sequence of the case statements and how it will effect the outcome. I think he was suppose to test the code and learn. Personly instead of changing x to equal 1 I would simply change the case 1: to case 0: and case 0: to case 1: keeping the outputs in the same order. If the point was to get all three to print. :P

    Like :
    Code:
    main()
    {
    
     int x=0;
     switch(x)
     {
      case 0: printf( "One" );
      case 1: printf( "Zero" );
      case 2: printf( "Hello World" );
     }
     }

  3. #3
    Banned ಠ_ಠ's Avatar
    Join Date
    Mar 2009
    Posts
    687
    Quote Originally Posted by strickyc View Post
    I think the problem was to illustrate the out of order sequence of the case statements and how it will effect the outcome. I think he was suppose to test the code and learn. Personly instead of changing x to equal 1 I would simply change the case 1: to case 0: and case 0: to case 1: keeping the outputs in the same order. If the point was to get all three to print. :P

    Like :
    Code:
    main()
    {
    
     int x=0;
     switch(x)
     {
      case 0: printf( "One" );
      case 1: printf( "Zero" );
      case 2: printf( "Hello World" );
     }
     }
    You'd rather change 2 things than 1?
    ╔╗╔══╦╗
    ║║║╔╗║║
    ║╚╣╚╝║╚╗
    ╚═╩══╩═╝

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Totally confused on assigment using linked lists
    By Uchihanokonoha in forum C++ Programming
    Replies: 8
    Last Post: 01-05-2008, 04:49 PM
  2. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  3. What kind of programs should I start writing?
    By Macabre in forum C++ Programming
    Replies: 23
    Last Post: 04-12-2003, 08:13 PM
  4. Replies: 2
    Last Post: 05-10-2002, 04:16 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM