Problem of the code?

Joined
Mar 13, 2019
Messages
2
Reaction score
0
C:
#include<stdio.h>
int main( void )
{
    int sum = 0;
    float average;
    int weight_1, weight_2;
    printf( "1.weight> " );
    scanf( "%d", &weight_1 );
    sum = sum + weight_1;
    printf( "2.weight> " );
    scanf( "%d", &weight_2 );
    sum = sum + weight_2;
    average = sum / 2.0;
    printf( "Average: %f\n", &average );
    return 0; 
}

When i run, code gives the average as 0.00000000. What's the problem?
 
Last edited by a moderator:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,979
Messages
2,570,185
Members
46,728
Latest member
FernMcmull

Latest Threads

Top