#include <stdio.h>
int main()
{
int k,l; // if k and l are integer values
int i=2,j=3;
float a,b;
// i/j*j is the same in C language as (i/j)*j
// j/i*i is the same in C language as (j/i)*i
k=i/j*j; // 2/3 = 0 (because of C language specification, int/int = int), 0*3 = 0 (it's clear)
l=j/i*i; // 3/2 = 1 (because of C language specification, int/int = int), 1*2 = 2 (it's clear)
a=i/j*j; // 2/3 = 0 (because of C language specification, int/int = int), 0*3 = 0 (it's clear), a-floating number => a=0.000000
b=j/i*i; // 3/2 = 1 (because of C language specification, int/int = int), 1*2 = 2 (it's clear), b-floating number => b=2.000000
printf("%d %d %f %f", k, l, a, b); // output is "0 2 0.000000 2.000000"
return 0;
}
Comments
Dear visitor, please use panel for submitting new questions.
#include int main() { int x=10,y=20; if(x==y); printf("\n %d %d",x,y); return 0; } Actually there is no semicolon after the if statement know sir. In this question there is semicolon after if statement. what will be the output?.please explain the concept behind this sir.
Leave a comment