edited by
4,067 views
0 votes
0 votes

what is the output for the below program ?

main()

{

float x=1/2;

float y=1/2.0;

printf("%f, %f", x,y);

}

A) 0.500000, 0.500000

B) 0.500000, 0.000000

C) 0.000000, 0.000000

D) 0.000000, 0.500000

edited by

1 Answer

Best answer
7 votes
7 votes
#include <stdio.h> 
int main() { 
    float x=1/2; // integer airthematic x = 0 
    float y=1/2.0; // y = 0.50
    printf("%f, %f", x, y); 
    // output = 0,0.50 
    return 0; 
    }
selected by

Related questions

0 votes
0 votes
0 answers
2
aimhigh asked Jan 8, 2019
1,233 views
#include<stdio.h>void main(){int p=-8;int i= (p++,++p);printf("%d\n",i);}
0 votes
0 votes
1 answer
4
Desert_Warrior asked May 16, 2016
2,310 views
#include<stdio.h int main() { int a = 5; int b = ++a * a++; printf("%d ",b); return 0; }(a) 25 (b) 30 (c) 36 (d) Undefined Behavior