TCS
Company
Programming
Program
What is the output of:
main( )
{
float a = 5, b = 2 ;
int c ;
c = a % b ;
printf ( "%d", c ) ;
}
Read Solution (Total 24)
-
- Error...
We cannot use % operator for floating point variables...
It should be used only with integer variables...
- 10 years agoHelpfull: Yes(38) No(1)
- 1..............................
- 10 years agoHelpfull: Yes(4) No(2)
- 1
a%b=5%2=remainder 1 - 10 years agoHelpfull: Yes(3) No(4)
- c is an int variable
so 5/2=2.5
c is int so c=2
- 10 years agoHelpfull: Yes(2) No(8)
- We cannot used modulos % operator in float data type.........only used in int value..
- 7 years agoHelpfull: Yes(2) No(0)
- error we cant use % with float and double variables
- 10 years agoHelpfull: Yes(1) No(0)
- ans:- 1
the reason is 5%2 will give 1 as remainder - 9 years agoHelpfull: Yes(1) No(2)
- 1
as 5/2=1.0,but we are storing it to int.So the value of the float will be truncated.
- 9 years agoHelpfull: Yes(1) No(0)
- 2 as return type of c is int.....
- 10 years agoHelpfull: Yes(0) No(3)
- Error
Invalid operator - 10 years agoHelpfull: Yes(0) No(0)
- 2 becoz c is an integer no.
- 9 years agoHelpfull: Yes(0) No(0)
- erroe because float values cannot be stored in an integer type value!
- 9 years agoHelpfull: Yes(0) No(0)
- error ....
illegal statement
%operator is not allowed hear - 9 years agoHelpfull: Yes(0) No(0)
- % operation illegal in float datatype...
- 9 years agoHelpfull: Yes(0) No(0)
- % operator cannot be performed for the floating values. As a and b are declared under float variable we will get error while executing..
- 9 years agoHelpfull: Yes(0) No(0)
- ans: error
we can not use " % " operator on float variables
so it gives an error. - 9 years agoHelpfull: Yes(0) No(0)
- 0 since float does not operate for modulo
- 9 years agoHelpfull: Yes(0) No(0)
- 5.000000%2.000000=1.000000
since c is int ans=1 - 8 years agoHelpfull: Yes(0) No(1)
- o/p:1
bcoz a%b=5%2=1(it gives remainder). - 7 years agoHelpfull: Yes(0) No(0)
- it will throw an compile time error .illegal float usage.
- 7 years agoHelpfull: Yes(0) No(0)
- float variables cannot be used %.its error
- 7 years agoHelpfull: Yes(0) No(0)
- output: 1
easy answer - 7 years agoHelpfull: Yes(0) No(0)
- here float%float cannot be excuted because % operator cannot be applied on float values so it gives error.If you use fmod(a,b)then it gives 1 as output.
- 6 years agoHelpfull: Yes(0) No(0)
- 1.As c varible is interger it will give remainder of interger type.
- 1 year agoHelpfull: Yes(0) No(0)
TCS Other Question