Construct the flowchart and code the program to gauge the amount of inflation over the past year. The program asks for the price of an item (e.g. jeans) both one year ago and today. Then, it estimates the inflation rate as the difference in price divided by the price a year ago. Print out the inflation rate (in percentage value), amount of inflation, and the estimated price of the item (same item) one year from now two years form now. The increase in price of the item is estimated as the inflation rate times the current price.
#include<stdio.h>
#include<conio.h>
int main(void)
{
float priceT, priceA,am_inflation;
float inflation, aYrFNow, twoYrsFNow;
clrscr();
printf("\n\tEnter Price of Item today: ");
scanf("%f",&priceT);
printf("\tEnter Price of Item a year ago: ");
scanf("%f",&priceA);
am_inflation =priceT-priceA;
printf("\n\n\tAmount of Inflation: P %.2f",am_inflation);
inflation = ((am_inflation)/priceA*100);
printf("\n\n\tInflation: %.2f %\n",inflation);
aYrFNow = priceT+(priceT*inflation);
printf("\n\tPrice of Item a year from now: P %.2f\n",aYrFNow);
twoYrsFNow = aYrFNow+(aYrFNow*inflation);
printf("\n\tPrice of item two years from now: P %.2f",twoYrsFNow);
getch();
}
Showing posts with label C PROGAMMING. Show all posts
Showing posts with label C PROGAMMING. Show all posts
Thursday, October 21, 2010
LITER TO GALLON
A liter is 0.264197 gallons. Read the number of liters consumed by the car and the number of miles traveled. Then output the no. of miles per gallon the car delivered.
#include<stdio.h>
#include<conio.h>
int main(void)
{
float Liter,MilesT,gallon,Miles_gallon;
clrscr();
printf("Enter the liters that was consumed:");
scanf("%f",&Liter);
printf("Enter the Miles that was traveled:");
scanf("%f",&MilesT);
gallon =Liter*0.264197;
Miles_gallon =MilesT/gallon;
printf("The number of miles per gallon is: %.2f",Miles_gallon);
getch();
}
#include<stdio.h>
#include<conio.h>
int main(void)
{
float Liter,MilesT,gallon,Miles_gallon;
clrscr();
printf("Enter the liters that was consumed:");
scanf("%f",&Liter);
printf("Enter the Miles that was traveled:");
scanf("%f",&MilesT);
gallon =Liter*0.264197;
Miles_gallon =MilesT/gallon;
printf("The number of miles per gallon is: %.2f",Miles_gallon);
getch();
}
Wednesday, October 20, 2010
C PROGAMMING
#include<stdio.h>
#include<conio.h>
void main()
{
int PP,TPriceB;
clrscr();
printf("\n\tEnter the number of pingpong balls was purchased:^");
scanf("%d",&PP);
if(PP>=5)
{
TPriceB =PP*18;
printf("\n\tOne ball costs P 18.");
}
else
{
TPriceB =PP*20;
printf("\n\tOne ball costs P 20.");
}
printf("\n\n\tThe total price of the pingpong balls purchased: P %d",TPriceB);
getch();
}
FOR MORE INFORMATION
#include<conio.h>
void main()
{
int PP,TPriceB;
clrscr();
printf("\n\tEnter the number of pingpong balls was purchased:^");
scanf("%d",&PP);
if(PP>=5)
{
TPriceB =PP*18;
printf("\n\tOne ball costs P 18.");
}
else
{
TPriceB =PP*20;
printf("\n\tOne ball costs P 20.");
}
printf("\n\n\tThe total price of the pingpong balls purchased: P %d",TPriceB);
getch();
}
FOR MORE INFORMATION
Subscribe to:
Posts (Atom)