Evaluation activity hours per minutes

Asked

Viewed 825 times

1

Question (2): Make a program that receives an hour formed per hour and minutes (a real number), calculate and show the time typed only in minutes. Consider that:

  • for four and a half (4:30), type 4.30;
  • for four and fifty (4:50), type 4.50;
  • minutes range from 0 to 59

What I tried to do:

#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<locale.h>

int main(){
    setlocale(LC_ALL, "portuguese");
    float hora, min;


        printf("Insira as horas formatada 0.00: ");
        scanf("%f", &hora);

        min = hora;

            hora = (hora * 60);
            min = (min * 100)%100;
            hora = hora + min;

        printf("%2.0f minutos", hora);



}

But that mistake always comes:

C: Users Lelre Desktop EVALUATIVE ACTIVITY 2.c|17|error: invalid operands to Binary % (have 'float' and 'int')|

For the searches I can not use mod with values float but there is some way to transform float for whole to receive the remainder of the division and add to the minutes?

1 answer

2

  • Thank you so much for helping @bigown

Browser other questions tagged

You are not signed in. Login or sign up in order to post.