Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program for investment problem using while loop

Posted By: Beatriz Silva     Category: C Programming     Views: 5092

Write a Program for investment problem using while loop.

Code for Program for investment problem using while loop in C Programming

/*--------------------- INVESTMENT PROBLEM --------------------*/
#define PERIOD 10 #define PRINCIPAL 5000.00 /*-------------------- MAIN PROGRAM BEGINS --------------------*/
main() { /*------------------- DECLARATION STATEMENTS ----------------*/
int year; float amount, value, inrate; /*------------------- ASSIGNMENT STATEMENTS -------------------*/
amount = PRINCIPAL; inrate = 0.11; year = 0; /*------------------ COMPUTATION STATEMENTS -------------------*/
/*--------------- COMPUTATION USING While LOOP ----------------*/
while(year <= PERIOD) { printf(“%2d %8.2f\n”,year, amount); value = amount + inrate * amount; year = year + 1; amount = value; } /*----------------------- while LOOP ENDS ---------------------*/
} /*------------------------ PROGRAM ENDS -----------------------*/
  
Share: 


Didn't find what you were looking for? Find more on Program for investment problem using while loop Or get search suggestion and latest updates.

Beatriz Silva
Beatriz Silva author of Program for investment problem using while loop is from Salvador, Brazil.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Vrajesh Bhavsar from India Comment on: Sep 01
Can you please explain me this program?
i didnt understand what is this!
and i also seen it in "Programming in ANSI C" book. but i dont understand it!
.

View All Comments