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:
Ad

Advertisements

Ad

Advertisements


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

Top