Friday, July 31, 2009

Programming with 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:





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.

Programming with c?
Do not you think that is lot of homework ?
Reply:This questions seems professional, i would recommenced, if you cannot do it yourself, you can take professional help and ofcourse this never comes free, i know professional who do this type of homework, try contact ankurjain@excitonpublications.com they have nominal charges around $50 per answer.





try this, hope they will help





regards
Reply:Do your homework yourself. Who do you think has that much time to read through your zillion words long questions and then give you a ready made answer. %26gt;.%26lt; Have some decency!





Write down your code, and then if you are stuck somewhere, ask us and we'll help you.
Reply:Seriously do your own homework. Im tired of "questions" like these. Are we allowed to report them? Btw, if you can't handle an assignment like this without asking someone else to do it for you, drop the class. THIS IS SIMPLE! A few cin's, a few cout's, can count the number of variables required with my fingers and a couple if's or switch statements. Read the material your instructor provided you with and then come back with specific questions. Those we will answer.
Reply:hey lareb, i hope that i can make the program for you, it is simple, all you have to do is email me at my id, so that i get your email, and i will reply / post the answer in the cpp format for you,





i am not like others i just want to help you,


try me and see if i am helpful, ok


contact me at :





qazeeassad@gmail.com


qazeeassad@yahoo.com





both are ok but first try gmail,


i will be waiting for your email ok


as there is only 1 day left in your assignment


see you


No comments:

Post a Comment