A simple calculator is a calculator that performs some basic operations like ‘+’, ‘-’, ‘.’, ‘/’. A calculator does basic operation in a fast way. We will use switch statement to make a calculator. In below c programming code example, the user is prompted to choose the operations(i.e. Addition, subtraction etc) to be performed and then prompted to key in the values which are used to perform the operations. Then, the result will be shown as output to the user. Sample C programming code for Calculator Application. Code is too long to put here. Try asking the question on stackoverflow, where people have the space to write out code. I suggest (if you're really passionate) you learn C and make the code yourself. It won't be a hard code (some people write one as they learn C). How To End A Program In Dev C++ Bloodshed Dev C++ Ubuntu Simple Car Racing Game Code In Dev C++ How To Do Auto-tune In Tik Tok Dev C++ 4.9 9.2 Download Windows 7 Eris E 4.5 Studio One Auto Tune Free Download Legal Traktor Pro 2 Effects Tutorial Dev C++ Calculator Code.
- Dev C 2b 2b Calculator Code Java
- Dev C 2b 2b Calculator Codes
- Dev C 2b 2b Calculator Code C++
- Dev C 2b 2b Calculator Code C
Here you will learn how to code your first basic C++ Program: The Body Mass Index (BMI) Calculator!
DISCLAIMER: These instructions are for the sole purpose of learning the basics of input and output in C++. Do not base any medical decisions on results received from this program.
Note: To learn a little more about a subject in blue, click on the word for a brief definition.
Step 1: Download Visual Studio
- Go to http://www.visualstudio.com/downloads/download-visual-studio-vs
- Scroll down and click on “Visual Studio C++ 2010 Express”.
- Click “Install now”.
- Sign in to Microsoft (or sign up).
- Follow the instructions to install.
Step 2: Create New Project
- Click File->New->Project.
- Click “Visual C++” in the toolbar and select “Empty Project”.
- Type “My First Project” into the Name textbox.
- Click “OK”.
Step 3: Create the Source File
- In the “Solution Explorer” toolbar, right click on “Source Files”, then click Add->New Item.
- Click “Visual C++” under Installed Templates and select “C++ File (.cpp)”.
- Type “MyFirstProject” into the Name textbox.
- Click “Add”.
Step 4: Include your Standard Libraries
- Write these two statements to include all of the standard libraries that we will need.
Step 5: Create your main Function
- Write this statement to declare a function called “main”.
- Write an opening and closing curly bracket to mark the beginning and end of the function.
Step 6: Create Variables
- Create a variable with a type of “int”, a name of “height”, and a value of “0”. You will do this by declaring the type first, then the name, and finally setting the variable “height” equal to it’s value, “0”.
- Use a semicolon to end your statement.
- Repeat this step to declare the variables “weight” and “BMI”, as shown in the picture.
Step 7: Write to the User
- To write a message to the user, type “cout <<” and then type your message within double-quotes.
Step 8: Read from the User
- To read a message from the user, type “cin >>” and then type the variable that you would like to save the input into.
- For this first example, we will save their response into the “height” variable. This will overwrite the “0” that we saved into it initially, and save whatever the user types.
Step 9: Repeat Steps 7 and 8
- Now you know how to read and write messages to the user! Do this again to ask for and save the user’s weight.
Step 10: Calculate the user’s BMI
- You now have all of the information that you need to calculate the user’s BMI! The calculation is complex, but the computer calculates these mathematical expressions almost instantly. See the picture below for the equation.
Step 11: Display their results
- Their BMI is now saved into a variable, and we need to display it to the user.
- Use the “cout” command again to display a message to the user. Start by printing the message “Your BMI is: ” and then add the variable BMI by using the “+” operator, as shown in the picture.
- Print out the BMI information chart so that they can interpret the result.
Step 12: Pause the Program
Dev C 2b 2b Calculator Code Java
- Use the system(“pause”) command to pause your program, as shown in the picture.
Step 13: Run your Program
- Hit the little green triangle button on the top toolbar to compile and execute your code.
- The final result should look like this:
- If you have any issues, please reference our “Errors” page for suggestions.
Write a C++ Program to Calculate Compound Interest. Here’s simple Program to Calculate Compound Interest in C++ Programming Language.
What is compound interest?
It is the addition of interest to the principal sum of a loan or deposit, or in other words, interest on interest. It is the result of reinvesting interest, rather than paying it out, so that interest in the next period is then earned on the principal sum plus previously-accumulated interest.
It may be contrasted with simple interest, where interest is not added to the principal, so there is no compounding.
Annual compound interest formula
The formula for annual compound interest, including principal sum, is:
A = P (1 + r/n) (nt)
A = the future value of the investment/loan, including interest
P = the principal investment amount (the initial deposit or loan amount)
r = the annual interest rate (decimal)
n = the number of times that interest is compounded per year
t = the number of years the money is invested or borrowed for
Note that this formula gives you the future value of an investment or loan, which is compound interest plus the principal. Should you wish to calculate the compound interest only, you need this:
Total compounded interest = P (1 + r/n) (nt) – P
This program will read principal, rate and time in years and then print compound interest on entered principal for given time period.
Here is source code of the C++ Program to Calculate Compound Interest. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.
SOURCE CODE : :
Dev C 2b 2b Calculator Codes
cout<<'nThe Calculated Compound Interest is = '<<ci<<'n';