Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

positive difference


  • Please log in to reply

#1
moonbeam2006

moonbeam2006

    New Member

  • Member
  • Pip
  • 1 posts
hi, :whistling:

i'm new and i'm currently taking visual logic programming course at my local college and well i know this is probrable a very easy problem but i need help i've never been good in math and it's frustrating that i can't seem to figure this out!!! anyway i need help creating a flow chart where i input two values and it displays their positive difference for ex. if the first input is 6 and the second input is 9 then the positive difference is 3. likewise, if the first input is 9 and the second input is 6 the output is still a positive 3.


it sound simple and i just know if i can get at least a little help then maybe my brain will light up!!!! :blink:
  • 0

Advertisements


#2
greatmightypoo

greatmightypoo

    Member

  • Member
  • PipPip
  • 75 posts
I think your looking for something like this:

1 INPUT A 
2 INPUT B
3 IF A - B < 0 THEN GOTO 6
4 PRINT A - B
5 END
6 PRINT B - A 
7 END

So if A = 9 and B = 6 then you will get 3. If A = 6 and B = 9, then A - B would equal a value less than 0 (negative), thus telling the program to reverse the numbers to B - A which will equal 3.
  • 0

#3
gust0208

gust0208

    Member

  • Member
  • PipPipPip
  • 311 posts

I think your looking for something like this:

1 INPUT A 
2 INPUT B
3 IF A - B < 0 THEN GOTO 6
4 PRINT A - B
5 END
6 PRINT B - A 
7 END


This is a great answer! I like the basic/assembly style of writing the visual logic code and it does a great job of presenting the logical flow. I will use this style for any future visual logic questions.

Cheers,
Tom
  • 0

#4
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP
Or just:

abs(A-B)

abs is the standard convention for absolute value.
  • 0

#5
Yoboydj

Yoboydj

    New Member

  • Member
  • Pip
  • 1 posts
Can you explain the above asnwer some more i'm trying to use it but my output keeps getting errors any reasons why?
  • 0

#6
Spike

Spike

    nOoB

  • Member
  • PipPipPipPip
  • 1,357 posts

I think your looking for something like this:

1 INPUT A 
2 INPUT B
3 IF A - B < 0 THEN GOTO 6
4 PRINT A - B
5 END
6 PRINT B - A 
7 END

So if A = 9 and B = 6 then you will get 3. If A = 6 and B = 9, then A - B would equal a value less than 0 (negative), thus telling the program to reverse the numbers to B - A which will equal 3.

There would be no need to compare against a zero though. Would it not be more sufficient to test it against itself. Eg.

3 IF A > B THEN GOTO 6

Can you explain the above asnwer some more i'm trying to use it but my output keeps getting errors any reasons why?

Here is a screenshot:
Posted Image


Peace Out :)
Spike
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP