![]() |
|
#1
|
|||
|
|||
Help needed on visual C++ basic math programHi Guys,
I am using Visual Basic C++ 6.0 edition. I need help on creating a basic program that can: 1. Add 2. Subtract 3. Multiply 4. Division It should take no longer than 10 minutes if you are C++ savy. -------------------- Use float The screen should prompt user to enter two numbers: Enter a number: Enter a number: Result of Addition = Result of Subtraction = Result of Multiplying = Result of Division = xoBeBExo where you guys from? |
|||
|
#2
|
||||
|
||||
Re: Help needed on visual C++ basic math programHi xoBeBExo,
Welcome to the GIDForums™. ![]() Did you read the Guidelines? There are many people from many countries in this forum. You can look forward to meet them in this forum and have a enjoyable stay. I am from India. Where are you from? Since you mentioned that you use Visual C++, i assume that you use C++ programming language. Ok. Lets start thinking how to do this program. Quote:
Lets start from a simple program. I hope you know: 1. Every executable program should have a main function: CPP / C++ / C Code:
2. We should include the iostream header file using : CPP / C++ / C Code:
CPP / C++ / C Code:
4. We can add comments using //. Comments help in understanding the program better. So, here is the prototype of a typical C++ program: CPP / C++ / C Code:
Now, we have created a prototype. We shall see next, how to use variables to store numbers and print them. CPP / C++ / C Code:
As you see the comments, we create an integer say i and then store some value in the integer. The we are printing by using the cout statement. So, cout<<"The number is " will print "The number is " and "<< i;" prints the number i. Try this program in your visual C++. Next, we'll see how to manipulate variables. Say addition first. CPP / C++ / C Code:
the store some value in the numbers and add them using the addition symbol "+" and store the sum in the variable sum. so, CPP / C++ / C Code:
Now, how to get the user input? We can use the cin statement.. Here is the sample program. CPP / C++ / C Code:
Here is a sample output from the program: Code:
So, we have successfully created a program that adds two numbers and print the sum. Now, here is what you should do for subtraction, multiplication and division: 1. Create separate variables to store the result of subtraction, multiplication and division. 2. Get the input for the two numbers. 3. Do the corresponding action for subtraction, multiplication and division and then store it in variables. i.e num1 - num2 for subtraction etc.. 4. Print the result. Best Regards, ![]() Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#3
|
||||
|
||||
Re: Help needed on visual C++ basic math programnicely explained paramesh
|
|
#4
|
||||
|
||||
Re: Help needed on visual C++ basic math programQuote:
)and Welcome to the GIDForums™. ![]() Best Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#5
|
||||
|
||||
Re: Help needed on visual C++ basic math programQuote:
Not just India ! I've read you are from Madras (or Fort St. George) ! __________________
It's actually a one time thing (it just happens alot). |
|
#6
|
||||
|
||||
Re: Help needed on visual C++ basic math programQuote:
![]() Fort St. George is in Chennai. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
Recent GIDBlog
Vista ?Widgets? on Windows XP by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| GIDForums enables New [VB] Visual Basic bbcode. | admin | .NET Forum | 0 | 01-Oct-2005 13:08 |
| Enter key in basic c program | hopesfall | C Programming Language | 2 | 26-Mar-2005 16:09 |
| Help with simple math table program (was a SIMPLE program) | Bubba | C Programming Language | 3 | 09-Mar-2005 12:40 |
| What is "Ambigious symbol" ??*( a compilation error) | small_ticket | C++ Forum | 2 | 07-Jan-2005 21:10 |
| C Currency Conversion program help needed | mutt | C Programming Language | 1 | 13-Jun-2004 15:14 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The