Take one sheet of paper, and fold it in half, then fold it in half again, and ag
ID: 3758268 • Letter: T
Question
Take one sheet of paper, and fold it in half, then fold it in half again, and again, and again. Can you fold it 30 times? Pretending that you can (you probably won’t be able to fold it more than eight times), how thick would it be after 30 times? Assume the paper is 1/200 cm thick. Write a program to solve this puzzle. Your program should have one user input that is the number of folds. The program should display the thickness of the paper in centimeters in the following way: “The thickness after X folds will be Y cm”. (There are several, equally correct, ways to solve this problem. To recognize the pattern, you may want to write out by hand the answer for 0,1, 2, 3, 4, 5, 6, … n folds.)
solved in C ++
Explanation / Answer
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
static double th = 0.005;
int folds=-1;
double thck;
while(folds<0)
{
cout<<" Enter the number of folds [>0] : ";
cin>>folds;
}
thck = th*pow(2,folds);
cout<<" The thickness after "<<folds<<" folds will be "<<thck<<"cm";
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.