#include<stdio.h>
#include<conio.h>
int main()
{
int a=9,b=2;
float c;
int i1;
int i2;
float f1;
float f2;
clrscr();
i1=9/2; //integer divided by integer
printf("\n1--> %d",i1); //Answer=4
printf("\n2--> %d",9/2); //Answer=4
i2=9.0/2; //implicit typecasting
printf("\n3--> %d",i2); //Answer=4
printf("\n4--> %d",9.0/2); //Answer=0//Mismatch
f1=9.0/2;
printf("\n5--> %d",f1); //Answer=0//Mismatch
f2=9/2; //integer divided by integer//implicit typecasting
printf("\n6--> %d",f2); //Answer=0//Mismatch
i1=9/2; //integer divided by integer
printf("\n7--> %f",i1); //Answer=0.000000//Mismatch
printf("\n8--> %f",9/2); //Answer=0.000000//Mismatch
i2=9.0/2; //implicit typecasting
printf("\n9--> %f",i2); //Answer=0.000000//Mismatch
f2=9/2; //integer divided by integer//implicit typecasting
printf("\n10--> %f",f2); //Answer=4.000000
printf("\n11--> %f",9.0/2); //Answer=4.500000
printf("\n12--> %d",9.0+2.0); //Answer=0//Mismatch
printf("\n13-> %f",9.0-2.0); //Answer=7.000000
printf("\n14--> %d",9*2); //Answer=18
printf("\n15--> %d",-14%3); //Answer=-2
printf("\n16--> %d",-14%-3); //Answer=-2
printf("\n17--> %d",14%-3); //Answer=2
c=a/b; //integer divided by integer//implicit typecasting
printf("\n18--> %f",c); //Answer=4.000000
c=(float)a/b; //Explicit Typecasting
printf("\n19--> %f",c); //Answer=4.500000
getch();
return 0;
}
#include<conio.h>
int main()
{
int a=9,b=2;
float c;
int i1;
int i2;
float f1;
float f2;
clrscr();
i1=9/2; //integer divided by integer
printf("\n1--> %d",i1); //Answer=4
printf("\n2--> %d",9/2); //Answer=4
i2=9.0/2; //implicit typecasting
printf("\n3--> %d",i2); //Answer=4
printf("\n4--> %d",9.0/2); //Answer=0//Mismatch
f1=9.0/2;
printf("\n5--> %d",f1); //Answer=0//Mismatch
f2=9/2; //integer divided by integer//implicit typecasting
printf("\n6--> %d",f2); //Answer=0//Mismatch
i1=9/2; //integer divided by integer
printf("\n7--> %f",i1); //Answer=0.000000//Mismatch
printf("\n8--> %f",9/2); //Answer=0.000000//Mismatch
i2=9.0/2; //implicit typecasting
printf("\n9--> %f",i2); //Answer=0.000000//Mismatch
f2=9/2; //integer divided by integer//implicit typecasting
printf("\n10--> %f",f2); //Answer=4.000000
printf("\n11--> %f",9.0/2); //Answer=4.500000
printf("\n12--> %d",9.0+2.0); //Answer=0//Mismatch
printf("\n13-> %f",9.0-2.0); //Answer=7.000000
printf("\n14--> %d",9*2); //Answer=18
printf("\n15--> %d",-14%3); //Answer=-2
printf("\n16--> %d",-14%-3); //Answer=-2
printf("\n17--> %d",14%-3); //Answer=2
c=a/b; //integer divided by integer//implicit typecasting
printf("\n18--> %f",c); //Answer=4.000000
c=(float)a/b; //Explicit Typecasting
printf("\n19--> %f",c); //Answer=4.500000
getch();
return 0;
}
No comments:
Post a Comment