Skip to Content
author's profile photo Former Member
Former Member

basic syntax needed

how will i do this operation. i want to do something like

d = a*(-b)+c.

~rahul

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 28, 2005 at 06:22 AM

    Hi,

    data: d type i,
          a type i,
          b type i,
          c type i.
          
    a = 2.
    b = 3.
    c = 2.
    
    d = a * ( b * -1 ) + c.
    
    write: / d.

    Regards,

    Ville

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 28, 2005 at 06:29 AM

    Hi,

    I agree with the code that Ville has written.A little modification to the code will make it optimized.

    Try to reduce calculations in expressions.

    i.e instead of writing d = a * ( <b>b * -1</b> ) + c.

    you can say b = b * -1 before the expression comes.

    This is because if it is written inside a loop it would multiply each time with -1.So doing it once prior to the expression will save system stack.

    data: d type i,

    a type i,

    b type i,

    c type i.

    a = 2.

    b = 3.

    c = 2.

    d = a * ( b * -1 ) + c.

    write: / d.

    Regards,

    Ville

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 28, 2005 at 06:31 AM

    Hi,

    With reference to the above explanation please reward points if you have found it useful.

    Regards,

    Siva

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.