Skip to content

Latest commit

 

History

History
40 lines (37 loc) · 619 Bytes

data-types.md

File metadata and controls

40 lines (37 loc) · 619 Bytes

Data Types

Original code: (You'd get a format error)

#include <stdio.h>

int main(void)
{
    int score1=72;
    int score2=73;
    int score3=33;
    
    printf("Average: %f\n",(score1+score2+score3)/3);
}

First solution:

#include <stdio.h>

int main(void)
{
    int score1=72;
    int score2=73;
    int score3=33;
    
    printf("Average: %f\n",(score1+score2+score3)/3.0);
}

Second solution:

#include <stdio.h>

int main(void)
{
    int score1=72;
    int score2=73;
    int score3=33;
    
    printf("Average: %f\n",(score1+score2+score3)/(float)3);
}