Write a program to calculate how many squares are required

Assignment Help C/C++ Programming
Reference no: EM132101195

Can you please write the code in C++

Part A

There is an old story that the emperor wanted to thank the inventor of the game of chess and asked the inventor to name his reward.

The inventor asked for one grain of rice for the first square, 2 for the second, 4 for the third, and so on, doubling for each of the 64 squares. That may sound modest, but there wasn't that much rice in the empire!

Write a program to calculate how many squares are required to give the inventor at least 1000 grains of rice, at least 1,000,000 grains, and at least 1,000,000,000 grains.

You'll need a loop, of course, and probably an int to keep track of which square you are at, an int to keep the number of grains on the current square, and an int to keep track of the grains on all previous squares. We suggest that you write out the value of all your variables for each iteration of the loop so that you can see what's going on

Part B

Modify problem 3 to print the exact number of grains on all 64 squares. Use unsigned long long instead of int. (Note: This works on our two compilers, but may not work on other C++ compilers.)

Reference no: EM132101195

Questions Cloud

What is the amount of cash receipts from customers : Sales revenue was $1,095,307,000 for the year. What is the amount of cash receipts from customers?
How do you think so many social media platforms : How do you think so many social media platforms/messages are able to get away with deceptive advertisement? What are some examples??
Write a program that will use a recursive binary search : Write a program that will use a recursive binary search to locate an integer in a sorted array. The integer values will be provided in a file named dataarray.
Determine the highest sales in the report : Write a function that sorts the arrays sales data in ascending order. You may not use selection sort. Bubble sort example.
Write a program to calculate how many squares are required : There is an old story that the emperor wanted to thank the inventor of the game of chess and asked the inventor to name his reward.
Write a program that initially prompts the user for a file : Write a program that initially prompts the user for a file name. If the file is not found, an error message is output, and the program terminates.
Write a program calendar c that takes two inputs : Write a program calendar.c that takes two inputs: the start day of a month [Sunday is 0, Monday is 1,....., Saturday is 6] and the number of days in a month.
Create an array that holds random integers : Create an array that holds 1000 random integers between 1-1000. Please write a short paragraph, bullet points.
Prove the logical equivalence of conditional statement : Prove the logical equivalence of conditional statement and contrapositive of two propositional variables using truth table.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd