Click here to Skip to main content
15,885,546 members

Can anybody make that program for me pleaseeeeee!

Member 8720517 asked:

Open original thread
You have to write a computer program that will add 1/3 to itself a large number of times and to compare the result to multiplying 1/3 by the number of times 1/3 was added to itself. It is also to do the same thing with ½.
The program is to do this arithmetic twice, once using single precision (float) and once using double precision (double). Both of these will be in one program. Make certain you use a type for your counter that works with these large numbers.
Your program will do these additions 109 (1 billion) times. It is to print out the results, every power of ten times (10, 100, 1000, etc. up to 1 billion) along with the result of multiplying 1/3 to itself up to that point. Do NOT use fixed point to output the results. Each output should give the power of 10, the result from the addition of 1/3 to itself up to that point, the multiplication of 1/3 times the number of additions, the difference between these last two numbers, the result of adding ½ to itself up to that point, the multiplication of ½ times the number of additions up to that point, and the difference between these last two numbers. The program must output a header before this data explaining what the output is. Remember to do this for both single and double precision.
Make certain to have comments at the beginning of your program with your name, assignment number 3, date, and a brief explanation of the program. Also make certain to put comments within your program. Make certain to properly block the code in your program. Pay attention to the quality of your output, it should not be slopped all over the screen, but be in neat columns (perhaps use \t in the output statements). Remember you are only to do the multiplications when you output, do NOT do them every pass in the loop.
Items to think about:
1. Did you notice any difference between the results for ½ and 1/3?
2. Did you notice any difference between the results for single and double precision?
Tags: C++

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900