Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8693371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:31:54+00:00 2026-06-13T00:31:54+00:00

The assignment is to write a computer program that will add 1/3 to itself

  • 0

The assignment is 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.

#include<iostream>
#include<conio.h>
#include<math.h>
#include <limits>

using namespace std;
typedef std::numeric_limits< double > dbl;
int main()
{
    long size=1000000000;
    int count=0;
    long N=10;
    float nAdd=1;
    float nMul=1;

    cout.precision(dbl::digits10);
    cout<<"Iterration #\t\tAdd\t\t\tMul"<<endl;
    for(long  i=1; i<=size; i++)
    {
        nAdd+=1.0/3.0;
        nMul*=1.0/3.0;


        count++;
        if(count%N==0 && count!=0)
        {
            N*=10;
            cout<<i<<"\t\t"<<fixed <<nAdd<<"\t\t"<<fixed <<nMul<<endl;
        }
        if(count==size)
        {
            cout<<"Difference : "<<fixed <<nAdd<<" - "<<fixed <<nMul<<" = "<<fixed <<nAdd-nMul<<endl;
        }
    }
    getch();
    return 0;
}

so for i have done this
i don’t get it properly
what number i have to use which will be multiply by 1/3 or 1/3 will be added into it

can you guyz explain me this a lil
thanks alot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:31:55+00:00Added an answer on June 13, 2026 at 12:31 am

    add 1/3 to itself a large number of times

    This means that you should add ⅓ a bunch of times: ⅓ + ⅓ + ⅓ + ⅓ + …

    Then you’re supposed to compare the result of that calculation with the result of multiplying ⅓ by the number of times you added it. So for example if you add it together four times (⅓ + ⅓ + ⅓ + ⅓) then you compare that result with the result of ⅓ × 4.

    Mathematically the results should be the same, but the purpose of this assignment is to teach you something about how the computer performs the calculation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for an assignment I have to write a program that will take in an
For class I have an assignment: Write a C++ program that will output the
I have an assignment to Write a C program that allows a user to
Here is the assignment verbatim: 1.) Write a Java program that is a TCP
A while back we were given an assignment to write a c program that
My class assignment is to write a program that has the user input a
I have to write two files for an assignment, a client file that will
Here is my code for this simple assignment: Write the code that will read
The assignment is: Write a program that provides 20% discount for member who purchase
I've got an assignment to write a server program that accepts multiple clients. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.