Wednesday, March 14, 2012

Target-Heart-Rate Calculator

The formula for calculating your maximum heart rate in beats per minute is 220 minus your age in years.

Your target heart rate is a range that is 50-85% of your maximum heart rate.

However, maximum and target heart rates may vary based on the health, fitness, and gender of the individual.

Program below reads the user's birth year and the current year and computes the person's age, maximum heart rate and the target heart rate range.
/*
   title: Target-Heart-RateCalculator
   author: aeriqusyairi
   date: dec30 2011
*/
#include<stdio.h>
#include<stdlib.h>

int main(){
   int birth=0,current=0,age=0,maxrate=0;
   
   printf("Input your birth year: ");
   scanf("%d", &birth);
   
   printf("Input current year: ");
   scanf("%d", ¤t);
   
   age = current - birth;
   maxrate = 220 - age;
   
   printf("You are %d years old.\n", age);
   printf("Your maximum heart rate is %d beats per minute.\n", maxrate); 
   printf("Your target heart rate range is between %.2f to %.2f beats per minute.\n", 0.5 * maxrate, 0.85 * maxrate);
   
   system("pause");
   return 0;    
}

No comments:

Post a Comment