printf and scanf are most definitely C (though usable in C++) whereas cout and cin are C++ only.
The main drawbacks of printf / scanf are that you have to know the types of the variables you are inputting/outputting in order to get the format string correct. If the types ever change, the format string has to change also. cin/cout don't have this restriction; indeed cout << variable works so long as the type of variable is streamable.
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 vectorsPress 's' to subtract two vectorsPress 'm' to multiply two vectorsPress 'l to calculate the length of vector Press 'q' to quitPlease enter your choice: aAfter 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 : 2Enter second component of vector : 7The vector is : [ 2 , 7 ]Enter first component of vector : 6Enter second component of vector : 3The vector is : [ 6 , 3 ]The sum is [ 8 , 10 ]if the user enters ‘s’ then your output should be :Enter first component of vector : 2Enter second component of vector : 7The vector is : [ 2 , 7 ]Enter first component of vector : 6Enter second component of vector : 3The vector is : [ 6 , 3 ]The difference is [ -4 , 4]if the user enters ‘m’ then your output should be :Enter first component of vector : 2Enter second component of vector : 7The vector is : [ 2 , 7 ]Enter first component of vector : 6Enter second component of vector : 3The vector is : [ 6 , 3 ]The multiplication is 33After the menu if the user selects ‘l’ then your output should beEnter first component of vector : 1Enter second component of vector : 2The vector is : [ 1 , 2 ]The length is 2.23607After the menu if the user selects ‘q’ then your output should bePress any key to continue
thanks
here i am putting a needed program please any one will code it for me?
i want to 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 ‘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
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 ]
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
The multiplication is 33
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.
maan: when you have a question, please post in your own topic.
However, it is very unlikely that anyone will do you homework for you. This is a forum where people HELP other people with specific C++ problems. It's not a forum where people do your work/homework for you for free.
Dear Zaita
i dont want to make problem for someone but i am facing a hard problem nowadays. i need help and i will be be realy geartfull for any who do my only and one time that home work. i cannot pay anything thing at this time but i will try to pay your aal charges in future please any one write that program. thank you very much.
maan, nobody is going to just do your homework for you. People will help you if you make an honest effort to write the program yourself and post your non-working code. It does not benefit you academically to have someone do your work for you.
To be honest, any software professional will be able to write your program in 15 minutes, thus I'd expect you to at least have something running but non-working in an hour or so.
Zaita :
Lol i didn't even think about that (i didnt actually test the code as you might imagine ^^)
I just like being an idiot sometimes. Good spot n e hoo ^^
++
Maan: jsmith is right, we aren't here to do everyones homework. If you are not able to do the majority of it by yourself, technically you shouldn't be allowed to graduate. It just creates more useless developers in the workforce we have to clean code up after.
Here is a single sorting using the bubble algorithm.
It only compares the first letter of each name and also compares uppercase and lowercase... So to corectly compare them make all the first letters upper or lower and you can make a few changes to make it compare the rest of the names if the first letter is the same.