int main(int argc, const char * argv[])
{
    
    Person person;
    person.weightInKilos = 96;
    person.heightInMeters = 1.8;
    
    printf("person weighs %i kilograms \n", person.weightInKilos);
    printf("person is %.2f meters tall \n", person.heightInMeters);
    
    float bmi = bodyMassIndex(person);
    
    printf("person has a BMI of %.2f \n", bmi);
    
    
    //Challenge
    
    long secondsSince1970 = time(NULL);
    printf("It has been %ld seconds since 1970 \n", secondsSince1970);
    
    struct tm now;
    localtime_r(&secondsSince1970,&now);
    printf("The time is %d:%d:%d \n", now.tm_hour, now.tm_min, now.tm_sec);
    
    long fourMillionSeconds = secondsSince1970 + 4000000;
    struct tm future;
    localtime_r(&fourMillionSeconds,&future);
    
    printf("The date is %d-%d-%d \n", future.tm_mday, (future.tm_mon +1), (future.tm_year + 1900));
    
    
    return 0;
}
Exemple #2
0
int main(int argc, const char * argv[])
{
    Person person;
    person.weightInKilos = 96;
    person.heightInMeters = 1.8;
    float bmi = bodyMassIndex(person);
    printf("person has a BMI of %.2f\n", bmi);
    return 0;
}
Exemple #3
0
int main(int argc, const char * argv[]) {
    
    Person mikey;
    mikey.heightInMeters = 1.7;
    mikey.weightInKilos = 96;
    
    Person aaron;
    aaron.heightInMeters = 1.97;
    aaron.weightInKilos = 84;
    
    float bmi;
    bmi = bodyMassIndex(mikey);
    printf("Mikey has a BMI of %.2f\n", bmi);
    
    bmi = bodyMassIndex(aaron);
    printf("Aaron has a BMI of %.2f\n", bmi);
    
    return 0;
}
Exemple #4
0
int main(int argc, const char * argv[])
{
    Person Mikey;
    Mikey.heightMeters = 1.7;
    Mikey.weightInKilos = 96;
    
    Person Aaron;
    Aaron.heightMeters = 1.97;
    Aaron.weightInKilos = 84;
    
    float bmi; //create variable bmi to hold return value of bodyMassIndex()
    bmi = bodyMassIndex(Mikey);
    printf("Mikey has a BMI of %.2f\n", bmi);
    
    bmi = bodyMassIndex(Aaron);
    printf("Aaron has a BMI of %.2f\n", bmi);
    

    return 0;
}
Exemple #5
0
int main (int argc, const char * argv[])
{
    Person person;
    person.weightInKilos = 62;
    person.heightInMeters = 1.57;
    printf("person weight %i Kilograms\n", person.weightInKilos);
    printf("person is %.2f meters tall\n", person.heightInMeters);

    float bmi = bodyMassIndex(person);
    printf("person has BMI of %.2f\n", bmi);
    
    return 0;
}
int main(int argc, const char * argv[])
{
    Person felix;
    felix.weightInKilos = 82;
    felix.heightInMeters = 1.8;
    
    printf("felix weights %i kilogramms \n", felix.weightInKilos);
    printf("felix is %.2f meters tall \n", felix.heightInMeters);

    float bmi = bodyMassIndex(felix);
    printf("felix has a BMI of %.2f \n", bmi);
    
    return 0;
}
int main(int argc, const char * argv[])
{

    Person mikey;
    mikey.heightInMeters = 1.7;
    mikey.weightInKilos = 96;
    
    Person aaron;
    aaron.heightInMeters = 1.97;
    aaron.weightInKilos = 84;
    
//    printf("mikey is %.2f meters tall\n", mikey.heightInMeters);
//    printf("mikey weighs %d kilograms\n", mikey.weightInKilos);
//    printf("aaron is %.2f meters tall\n", aaron.heightInMeters);
//    printf("aaron weights %d kilograms\n", aaron.weightInKilos);

    float bmi;
    bmi = bodyMassIndex(mikey);
    printf("mikey has a BMI of %.2f\n", bmi);    
    
    bmi = bodyMassIndex(aaron);
    printf("aaron has a BMI of %.2f\n", bmi);
    return 0;
}
int main(int argc, const char * argv[])
{
    Person *x = (Person *)malloc(sizeof(Person));
    
    x->heightInMeters = 2.0;
    x->weightInKilos = 81;
    
    float xBMI = bodyMassIndex(x);
    printf("The body mass is %.2f\n",xBMI);
    
    free(x);
    
    x = NULL;
    
    return 0;
}
Exemple #9
0
int main(int argc, const char * argv[]) {
    //Allocate memory for one person struct
    Person *mikey = (Person *)malloc(sizeof(Person));
    
    //Fill in two members of the struct
    mikey->weightInKilos = 96;
    mikey->heightInMeters = 1.7;
    
    //Print out the BMI of the original person
    float mikeyBMI = bodyMassIndex(mikey);
    printf("Mikey has a BMI of %f.\n", mikeyBMI);
    
    //Let the memory be recycled
    free(mikey);
    
    //Forget where it was
    mikey = NULL;
    
    return 0;
}
Exemple #10
0
int main(int argc, const char * argv[])
{
    // Allocate memory for one Person structure
    Person *x = (Person *)malloc(sizeof(Person)); // malloc() claims space for a struct on a heap
    
    // Fill in two members of the structure
    x->weightInKilos = 81;
    x->heightInMeters = 2.0;
    
    // Print out the BMI of the original Person
    float xBMI = bodyMassIndex(x);
    printf("x has a BMI of = %f\n", xBMI);
    
    // Let the memory be recycled
    free(x);
    
    // Foreget where it was
    x = NULL;
    
    return 0;
}
Exemple #11
0
int main(int argc, const char * argv[])
{
    // Allocate memory for one Person struct in the "heap using malloc() function"
    Person *Mikey = (Person *)malloc(sizeof(Person)); //Mikey is a pointer to the heap of "sizeof() person"
    
    // Fill in two members of the struct
    Mikey->weightInKilos = 96;  // "->" is used to dereference pointer to actual value
    Mikey->heightMeters = 1.8;
    
    // Print out the BMI of the original Person
    float MikeyBMI = bodyMassIndex(Mikey);
    printf("Mike has a BMI of %.2f\n", MikeyBMI);
    
    // Let the memory be recycled
    free(Mikey);
    
    // Forget where it was
    Mikey = NULL;
    

}
Exemple #12
0
int main(int argc, const char * argv[]) {
    //为一个person结构分配内存
    Person *x = (Person *)malloc(Person);


    //为该结构的两个成员变量赋值
    x->weightInKilos = 96;
    x->heightInMeters = 1.8;


    //计算并输出BMI
    float xBMI = bodyMassIndex(x);
    printf("x has a BMI of %f\n", xBMI);


    //释放占用的内存,使之能够被重用
    free(x);


    //将指针变量赋为空
    x = NULL;
    return 0;
}
Exemple #13
0
void bodyMassCalc (Person p)
{
    float bmi = bodyMassIndex(p);
    printf("person has a BMI of %.2f\n", bmi);
}