Switch help plz

This is a discussion on Switch help plz within the C Programming forums, part of the General Programming Boards category; ghjgyj...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    15

    Switch help plz

    ghjgyj
    Last edited by joshua; 11-17-2005 at 09:48 PM.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    A switch statement requires an integral type. For scanf, use "%lf" for a double.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,077
    You have a few problems. One your case is a character and your switch is looking for a double (which should be an integer). Your second problem is you have no 0 case. You have a case for doing the calculation, then you have everything else. So if you fix problem one, yes the program will exit when you press 0, but it will also exit if you input 2 or 3.
    Sent from my iPadŽ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. ascii rpg help
    By aaron11193 in forum C Programming
    Replies: 18
    Last Post: 10-29-2006, 01:45 AM
  3. Switch
    By cogeek in forum C Programming
    Replies: 4
    Last Post: 12-23-2004, 06:40 PM
  4. Switch Case
    By FromHolland in forum C++ Programming
    Replies: 7
    Last Post: 06-13-2003, 04:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21