Lab2B2 - scanf("%lf",...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <stdio.h> #include <stdlib.h> #include <math.h> int main() { /*declare and initialize variables*/ double rate int year=2008, yearlimit, n, nlimit i /*prompt user input for variable values*/ printf("Enter the remaining forested area in acres: ") printf("Enter the available area for reforestation in acres: ") printf("Enter the rate of reforestation per acre per year(ex. 2 percent is .02): ")
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: scanf(&quot;%lf&quot;, &amp;rate) printf(&quot;Show data for how many future years?: &quot;) scanf(&quot;%i&quot;, &amp;yearlimit) printf(&quot;\n\n\n&quot;) /*&quot;do-while&quot; loop*/ do { printf(&quot;There will be %i acres in %i\n\n&quot;, n, year) p year = year + 1 n = n + (n*rate) n }while((year &lt;= 2008+yearlimit) &amp; (n &lt;= nlimit)) /*exit program*/ return EXIT_SUCCESS }...
View Full Document

Ask a homework question - tutors are online