0
Why 4.0 can't be declared as int??
My sir told me that if we declare int as a decimal it will take the number before the decimal . But when I entered it .It displayed an error. Plz help.
1 ответ
+ 1
if your sir has told exactly the same thing as you have written then your sir is wrong. In java it is not possible but it is possible in C. You have to perform type casting in java
//java program , output will be 4
class ABC
{
public static void main(String args[])
{
int a=(int)4.1;//typecasting
System.out.print(a);
}
}
//c program, output will be 4
#include<studio.h>
int main()
{
int a=4.1;
printf("%d",a);
return 0;
}