Thread: find out values

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    11

    find out values

    My question is how to find out
    how many values of the variable num
    used to completely test all branches of the
    following code?


    if(num>0)
    if(value<25)
    {
    value = 10*num;
    if(num<12)
    value=value/10;
    }
    else
    value = 20*num;
    else
    value=30*num;

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    22

    Thumbs up values...

    poorman,

    your code should be in the following style:
    _________________________________

    if(num>0)
    {
    if(value<25)
    {
    value = 10*num;
    if(num<12)
    value=value/10;
    }
    else
    value = 20*num;
    }
    else
    value=30*num;
    _________________________________

    how many values of the variable num
    used to completely test all branches of the
    following code?

    u can find out the number of values by debugging both using the lang's debugger or manually (e.g dry run).

    if u r using turbo c, then u can press F7 sequentially.
    then put the cursor below the 'num' variable and press Alt+F4.
    or u may use the menu bar.

    try it yourself.
    good luck.

    thanx...
    take care...
    Jackie

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    So for num you would need 3 values.

    num <= 0
    num > 0 && num < 12
    num > 0 && num >= 12

    But you have not got all cases then since you didn't take variable value into account.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. how do u find 2nd largest number??
    By juancardenas in forum C Programming
    Replies: 8
    Last Post: 02-14-2003, 08:28 AM
  3. unsigned char vs signed char and range of values
    By Silvercord in forum C++ Programming
    Replies: 5
    Last Post: 01-22-2003, 01:30 PM
  4. adding ASCII values
    By watshamacalit in forum C Programming
    Replies: 1
    Last Post: 12-26-2002, 07:16 PM
  5. How to read in empty values into array from input file
    By wpr101 in forum C++ Programming
    Replies: 5
    Last Post: 11-28-2002, 10:59 PM