How can i made vectors measuring program in DevC++

This is a discussion on How can i made vectors measuring program in DevC++ within the C Programming forums, part of the General Programming Boards category; How can i make the following Programe in c Plz reply me the full program according to the Dev C++. ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    2

    How can i made vectors measuring program in DevC++

    How can i make the following Programe in c Plz reply me the full program according to the Dev C++.

    Vectors
    Vectors are very important in mathematical computing and in computer graphics .Vector graphics is economical in its use of memory, as an entire line segment is specified simply by the coordinates of its endpoints. A vector can be represented by an arrow whose length represents the magnitude and the direction represents the vector direction.


    The above vector a can be represented as

    a = [a1, a2]

    The arithmetic operations can be performed in the following way:

    o Addition

    If a and b are two vectors

    a = [a1, a2]

    b = [b1, b2]

    then the sum of a and b is

    a + b = [a1+b1 , a2+b2]

    o Subtraction

    If a and b are two vectors

    a = [a1, a2]

    b = [b1, b2]

    then the difference of a and b is

    a - b = [a1-b1 , a2-b2]

    o Multiplication

    If a and b are two vectors

    a = [a1, a2]

    b = [b1, b2]

    then dot product of a and b is

    a . b = (a1 * b1 ) + ( a2 * b2)

    o Length of vector

    If a is a vector

    a = [a1, a2]

    then the length of vector a is

    length =

    Assignment

    Write a C++ program that performs the above mentioned operations on vectors with the help of above mentioned formulae. The program should have four user defined functions for the above operations.

    1) Addition
    2) Subtraction
    3) Multiplication
    4) Length

    The following menu of commands should be displayed at the start of program execution.

    Press 'a' to add two vectors

    Press 's' to subtract two vectors

    Press 'm' to multiply two vectors

    Press 'l to calculate the length of vector

    Press 'q' to quit

    Please enter your choice: a

    After the user selects a choice, prompt the user to enter the vector components on which the selected mathematical operation is to be performed, and then display the result. For example,

    if the user enters ‘a’ then your output should be:

    Enter first component of vector : 2
    Enter second component of vector : 7

    The vector is : [ 2 , 7 ]

    Enter first component of vector : 6
    Enter second component of vector : 3

    The vector is : [ 6 , 3 ]

    The sum is [ 8 , 10 ]

    if the user enters ‘s’ then your output should be :

    Enter first component of vector : 2
    Enter second component of vector : 7

    The vector is : [ 2 , 7 ]

    Enter first component of vector : 6
    Enter second component of vector : 3

    The vector is : [ 6 , 3 ]

    The difference is [ -4 , 4]

    if the user enters ‘m’ then your output should be :

    Enter first component of vector : 2
    Enter second component of vector : 7

    The vector is : [ 2 , 7 ]

    Enter first component of vector : 6
    Enter second component of vector : 3

    The vector is : [ 6 , 3 ]

    The multiplication is 33

    After the menu if the user selects ‘l’ then your output should be

    Enter first component of vector : 1
    Enter second component of vector : 2

    The vector is : [ 1 , 2 ]

    The length is 2.23607

    After the menu if the user selects ‘q’ then your output should be

    Press any key to continue …..

    Conditions that must be checked and fulfilled:

    Important Note
    1) If a user enters choice other then choices given in menu, then a message should be displayed “You have entered wrong choice:” and main menu should be displayed again.
    2) If a used enters a ,s or m then you have to take components of two vectors then do calculation on them
    3) If a user enters l then you have to take components of one vector only then do calculation on it.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    How about you read the rules on "Homework"?

    You do some work on the code, you post the code with some direct questions, we help you get things right. Note how that is different from "You post the assignment and we write the code for you".

    If you are stuck on something, perhaps you can describe what that sticking point is, and we can help you past that point.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 05:23 PM
  2. What's the best program you have ever made?
    By Kevin.j in forum A Brief History of Cprogramming.com
    Replies: 31
    Last Post: 10-02-2002, 12:29 PM
  3. Calc Program I made Tell me what u think
    By smog890 in forum C Programming
    Replies: 12
    Last Post: 06-09-2002, 11:56 PM
  4. Code structure of this program I made.
    By Seron in forum C++ Programming
    Replies: 0
    Last Post: 01-10-2002, 11:35 AM
  5. Will someone try this program I made?
    By SyntaxBubble in forum Windows Programming
    Replies: 6
    Last Post: 11-04-2001, 03:05 PM

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