"C Language" C programming--Rectification--(chapter III)--2

Source: Internet
Author: User
Tags pow

If the annual growth rate of GDP of our country is 9%, calculate 10 years after our country's gross domestic product and now compare the percentage of growth%//p = (1 + R) ^n   r--Annual growth rate  n--years  p--vs now multiples # include < Stdio.h> #include <math.h>int main () {double r = 0.09;double P;int n = 10;p = Pow ((1 + R), N);p rintf ("grew after 10 years %f times \ n ", p); return 0;}



Calculation of interest on deposits. There are 1000 yuan, want to save 5 years, according to the following 5 ways to Save://1, one deposit 5 years. 2, the first deposit 2 years, after the expiry of the principal and interest to save 3 years. 3, the first deposit 3 years, after the expiry of the principal and interest to save 2 years. 4, deposit 1-year period, after the expiry of the principal and interest after the 1-year period, the continuous deposit 5 times. 5, deposit current account. Current interest is settled once every quarter. 1-Year periodic interest: 4.14%;//2 periodic interest: 4.68%;//3 periodic interest: 5.4%;//5-year periodic interest: 5.85%;//Demand deposit interest: 0.72%; (demand deposit is settled once per quarter interest)//r--annual interest rate n--deposit years//1 years of this and: P = 1000* (1+r);//n-year principal and interest and: P = 1000* (1+n*r);//n/a 1-year deposit and principal: P = 1000* (1+r) ^n;//current deposit and interest: P = 1000* (1+R/4) ^4n--a quarter of interest and interest and #inclu  De <stdio.h> #include <math.h>int main () {double p1,p2,p3,p4,p5;double p0 = 1000.0;double R1 = 0.0414;double R2  = 0.0468;double R3 = 0.054;double R4 = 0.0585;double Huo = 0.0072;P1 = P0 * (1 + 5 * R4);p 2 = (P0 * (1 + 2 * r2)) *  (1 + 3 * R3);p 3 = (P0 * (1 + 3 * r3)) * (1 + 2 * r2);p 4 = P0 * POW ((1 + R1), 5);p 5 = p0 * POW (1 + HUO/4 );p rintf ("One deposit 5 years:%f\n", p1);p rintf ("Deposit 2 years, after maturity will be the principal and interest again 3 years:%f\n", p2);p rintf ("Deposit 3 years, after the expiry of the principal and interest again 2 years:%f\n", p3);p rintf ( "Deposit 1 years, after the expiry of the principal and interest to save 1 years, 5 consecutive times:%f\n", p4);p rintf ("Deposit current deposits. Current interest is settled quarterly:%f\n ", p5); return 0;}


Home purchase from the bank loans a sum of D, quasi-this monthly repayment amount is p, the monthly interest rate is r, calculate how many months to pay off. d = 300000  p = 6000  r = 0.01  to the month after the decimal point, second bit rounded//m = log (p/(p-d*r))/log (1+r) #include <stdio.h> #i Nclude <math.h>int Main () {float d = 300000.0;float p = 6000.0;float r = 0.01;float m;m = log (P/(p-d * r))/ Log (1 + R);p rintf ("needs%3.1f month to pay off \", m); return 0;}


Translate "China" into code, password rule: replace the original letter with the 4th letter behind the original letter. Requirements: First assign the initial value, and then respectively with Putchar and printf output # include <stdio.h>int main () {char C1 = ' C '; char c2 = ' h '; char c3 = ' i '; char C4 = ' n ' ; char c5 = ' a '; c1 = c1 + 4;C2 = C2 + 4;c3 = c3 + 4;c4 = c4 + 4;c5 = c5 + 4;printf ("Password is:%c%c%c%c%c\n", c1,c2,c3,c4,c5);p Utch AR (C1);p Utchar (C2);p Utchar (C3);p Utchar (C4);p Utchar (C5);p utchar (' \ n '); return 0;}


Set the circle radius r = 1.5, the cylinder height H = 3, the circumference is long, circle area, sphere surface area, sphere volume, cylinder volume//requirements: With scanf input data, take the decimal point two # # # # # <stdio.h>int Main () {float r,h; float C,s,sq,vq,vz;float pai = 3.1415926;printf ("Please enter circle Radius:"), scanf ("%f", &r);p rintf ("Please enter cylinder High:"); scanf ("%f", &h) ; c = 2 * Pai * r;s = Pai * r * r;sq = 4 * Pai * r * r;vq = (4/3) * Pai * R * r * R;vz = S * h;printf ("Circle circumference:%4.2f\n", c) ;p rintf ("Circle area is:%4.2f\n", s);p rintf ("Sphere surface area is:%4.2f\n", sq);p rintf ("Sphere volume is:%4.2f\n", VQ);p rintf ("Cylinder Volume:%4.2f\n", VZ); return 0;}


"C Language" C programming--Rectification--(chapter III)--2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.