0

Program 1:

#include<stdio.h>
int main(){
    float x = 0.1;
    if (x == 0.1)
        printf("IF");
    else if (x == 0.1f)
        printf("ELSE IF");
    else
    printf("ELSE");
    return 0;
}

Program 2:

#include<stdio.h>
int main{
    float x = 0.5;
    if (x == 0.5)
        printf("IF");
    else if (x == 0.5f) 
        printf("ELSE IF");
    else
        printf("ELSE");
    return 0;
}

First program Output: ELSE IF Second program Output: IF

Both programs are quite similar.But outputs are different.Why?

Biffen
  • 6,249
  • 6
  • 28
  • 36
Rituparna
  • 29
  • 8

0 Answers0