Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

error multiplication=0

0 votes
asked Nov 5, 2018 by Andres David Calderon Jimenes (120 points)
when i use this code:

#include <stdio.h>

int main()
{
    double euros;
    double precio1;
    double precio2;
    double precio5;
    double precio3;
    double precio4;
    double tiempo5;
    double tiempo3;
    double tiempo4;
    double tiempo2;
    double tiempo1;
    printf("Piensa en los últimos cinco juegos que has jugado.");
    printf("¿Cuántas horas le has echado al primero de ellos?");
    scanf("%lf", &tiempo1);
    printf("¿Y cuánto te costó?");
    scanf("%lf", &precio1);
    printf("¿Cuántas horas le has echado al segundo?");
    scanf("%lf", &tiempo2);
    printf("¿Y cuánto te costó?");
    scanf("%lf", &precio2);
    printf("¿Cuántas horas le has echado al tercero?");
    scanf("%lf", &tiempo3);
    printf("¿Y cuánto te costó?");
    scanf("%lf", &precio3);
    printf("¿Cuántas horas le has echado al cuarto?");
scanf("%lf", &tiempo4);
printf("¿Y cuánto te costó?");
scanf("%lf", &precio4);
printf("¿Cuántas horas le has echado al quinto?");
scanf("%lf", &tiempo5);
printf("¿Y cuánto te costó?");
scanf("%lf", &precio5);
euros = (precio1/tiempo1 + precio2/tiempo2 + precio3/tiempo3 + precio4/tiempo4 + precio5/tiempo5) / 5;
printf("¡Los últimos 5 juegos te han salido a %lf euros la hora!");

    return 0;
}

says te ha salido a 0 euros la hora if i puted euros = (precio1/tiempo1 + precio2/tiempo2 + precio3/tiempo3 + precio4/tiempo4 + precio5/tiempo5) / 5;

?

1 Answer

0 votes
answered Nov 6, 2018 by Mohamed Salama Mohamed Salama (140 points)

/* instead of using library <studio.h>, use <iostream> and do not forget " using namespace std;"

 and  you can copy the correction below i have tested it. 

*/

# include <iostream>

using namespace std;

int main()

{

double euros;
    double precio1;
    double precio2;
    double precio5;
    double precio3;
    double precio4;
    double tiempo5;
    double tiempo3;
    double tiempo4;
    double tiempo2;
    double tiempo1;
    printf("Piensa en los últimos cinco juegos que has jugado.");
    printf("¿Cuántas horas le has echado al primero de ellos?");
    scanf("%lf", &tiempo1);
    printf("¿Y cuánto te costó?");
    scanf("%lf", &precio1);
    printf("¿Cuántas horas le has echado al segundo?");
    scanf("%lf", &tiempo2);
    printf("¿Y cuánto te costó?");
    scanf("%lf", &precio2);
    printf("¿Cuántas horas le has echado al tercero?");
    scanf("%lf", &tiempo3);
    printf("¿Y cuánto te costó?");
    scanf("%lf", &precio3);
    printf("¿Cuántas horas le has echado al cuarto?");
scanf("%lf", &tiempo4);
printf("¿Y cuánto te costó?");
scanf("%lf", &precio4);
printf("¿Cuántas horas le has echado al quinto?");
scanf("%lf", &tiempo5);
printf("¿Y cuánto te costó?");
scanf("%lf", &precio5);
euros = (precio1/tiempo1 + precio2/tiempo2 + precio3/tiempo3 + precio4/tiempo4 + precio5/tiempo5) / 5;
printf("¡Los últimos 5 juegos te han salido a %lf euros la hora!");

    return 0;

}

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...