WAP to evaluate the following investment equation (C++)

V=P(1+r)n
and print the tables which would give the value of V for various combinations of the following values of P, r and n:
P: 1000, 2000, 3000, …, 10,000
r: 0.10, 0.11, 0.12, …, 0.19
n:1, 2, 3, …, 10
#include <iostream.h>
#include <math.h>
#include <conio.h>

int main(void)
{clrscr();
unsigned int P=1000, n=1, cell;
float r=0.10;
int i;
cout<<"\n\n";
for (i=1; i<=10; i++)
    {cout<<P<<"\t";
     P=P+1000;
     }
cout<<"\n";
for (i=1; i<=10; i++)
    {cout<<r<<"\t";
    r = r + 0.01;
    }
cout<<"\n";
for (i=1; i<=10; i++)
    {cout<<n<<"\t";
    n++;
    }
//reseting for final loop
P=1000;
r=0.10;
n=1;
cout<<"\n";
for (i=1; i<=10; i++)
    {cell= P*(pow(1+r, n));
    cout<<cell<<"\t";
        P+=1000;
        r+=0.01;
        n++;
    }
return 0;
}
problem 3.4 from E Balagurusamy’s Object Oriented Programming C++ (p 75)

Comments

  1. Thanks for commenting on onecore. I agree that here in india we have old compilers but you have to adjust with it till you complete your degree after that you can move on to Visual C++ Express or professional editions. Other than that there is also borland turbo explorer which is new and last updated in 2008. If you tried GCC before then you will feel comfortable with codeblocks, codelite and devc++.

    If you want to discuss more drop your questions on site. I'll reply them as blog posts.

    -- Mahesh

    ReplyDelete
  2. Re:

    "Hi Mahesh Sir,

    Thanks for the informative article

    “C++ 3.0 released in 1991,an updated version with the latest release of AT&T C++, it was targeted for windows 3.0 ”

    Somehow I seriously feel that this compiler and IDE is a technology dinosaur and we should move on to newer and current compilers.

    All PCs in my college have this, some even the TC 1 version, and most of my friends use these compilers. Some of them are very good coders, doing even graphics and all.

    Sir I am in my pre-final year of MCA and want to become a professional (C) C++ programmer and shall be beginning self-study in Dec.

    I don’t mind buying original software…please guide if there is any real utility (career wise) is using such dated compliers? Or Should I use newer ones like MS Visual Studio 2008 etc?

    Your guidance will help me a lot…

    Looking fwd to you reply…

    Warm regards,
    Gopal
    gopal1035@gmail.com"
    (link)


    Dear Mahesh Sir,

    Thanks for the reply...I was waiting for it :)

    I don't care what my college insists on. Sir I feel that we have to go out, do coding and make a living- so the onus is on the students and not teachers or lab in-charges to be up-to-date.

    I personally like MS Visual Studio and Microsoft is giving students free copies ( http://dreamsparkindia.com/ ), on only one condition that they'll not use it for commercial purposes.

    Sir, my doubt is that-

    "Is there any loss (career-wise, programming-skill wise) if a budding programmer begins his programming journey with Windows-based compilers like MS Visual Studio and does not do any programming in DOS-based compilers?"

    Looking fwd to hear from you

    Warm regards,
    Gopal

    ReplyDelete

Post a Comment

Kindly keep your comments on-topic and don't spam.