AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
C# Programming
Select a convenient declaration and initialization of a floating point number:
float somevariable = 12.502D
float somevariable = (Double) 12.502D
float somevariable = (float) 12.502D
float somevariable = (Decimal)12.502D
We cannot implicitly convert a “double” number directly to any other datatype.Here, its float we have to add the required datatype to number as : float somevariable = (float)12.502D; or Double somevariable = (Double)12.502D;
Correct way to define a value 6.28 in a variable ‘a’ where value cannot be modified ?
#define a 6.28F
pi = 6.28F
const float pi = 6.28F
const float pi
Const is a reserve keyword whenever they are declared with any variables.The value stored in that variable always remain fixed.Any modification done to change value of that variable results in error.Hence, options a, b and d are rejected because value is not declared fixed.Now, for value ‘c’ and ‘d’ only option ‘c’ is correct because for value ‘d’ while declaring a constant variable we need to provide a constant value too as provided in ‘c’. So, option ‘c’ is correct way of declaration of constant variable.
Why does a float variable stop incrementing at number ‘16777216’ in given code in C#?
float = 0 ;
while(true)
{
a++;
if ( a > 16777216 )
break;
}
Sign and Exponent for ‘16777217’ is same as for ‘16777216’
Mantissa is different for ‘16777216’ and ‘16777217’
Sign and Exponent for ‘16777217’ is different from ‘16777216’
None of the mentioned
16777216 is exactly 224, and would be represented as 32-bit float like so: sign = 0 (positive number) exponent = 24 (stored as 24 + 127 = 151 = 10010111) mantissa = . 0 As 32 bits floating-point representation: 0 10010111 00000000000000000000000 Therefore: Value = (+ 1) * 2 ^ 24 * (1. 0 + . 0) = 2 ^ 24 = 16777216 Now let’s look at the number 16777217, or exactly 224 + 1: sign and exponent are the same. Mantissa should have to be exactly 2-24 so that (+ 1) * 2 ^ 24 * (1. 0 + 2 ^-24) = 2 ^ 24 + 1 = 16777217 and here lies the actual problem . The mantissa cannot have the value 2-24 because it only has 23 bits, so the number 16777217 just cannot be represented with the accuracy of 32-bit floating points numbers.
Number of digits upto which precision value of float datatype is valid ?
Upto 6 digit
Upto 8 digit
Upto 9 digit
Upto 7 digit
Answer: Option (D)
Select appropriate difference between decimal, float and double data type in C# ? 1) Float and Double are floating binary point types while decimal is a floating decimal point type. 2) Precision difference for float is ‘7’ digit for double is ’15’ to ’16’ digit and for decimal is ’28’ to ’29’ digits. 3) Some values which cannot be exactly represented hence for those values float and double are more appropriate.
1
1, 2
1, 2, 3
2, 3
Answer: Option (C)
Select the output of the following set of code ?
staticvoid Main(string[] args)
int x =1;
float y =2. 4f;
short z =1;
Console.WriteLine((float) x + y * z -(x +=(short) y));
Console.ReadLine();
0.4000004
0.4000023
0.0400021
0.4000001
Answer: Option(D)
Output : 0.4000001
The Default value of Boolean DataType is ?
0
True
False
Answer: Option(C)
By Definition.
Which of the following format specifiers is used to print hexadecimal values and return value of output as Octal equivalent in C# ?
%hx for small case letters and %HX for capital letters
%x for small case letters and %X for capital letters
No ease of doing it. C# don’t provides specifier like %x or %O to be used with ReadLine() OR WriteLine().We have to write our own function
%Ox for smallcase letters and %OX for capital letters
Explained in answer itself.
A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored ?
ABCD
DCBA
0 * ABCD
Depends on big endian or little endian architecture
“Little Endian” means that the lower-order byte of the number is stored in memory at the lowest address, and the high order byte at the highest address. For example, a 4 byte Integer ABCD will be arranged in memory as follows: Base Address + 0 Byte 0 . Base Address + 1 Byte 1 . Base Address + 2 Byte 2 . Base Address + 3 Byte 3 . Intel processors (those used in PC’s) use “Little Endian” byte order. “Big Endian” means that the high-order byte of the number is stored in memory at the lowest address, and the low-order byte at the highest address. The same 4 byte integer would be stored as: Base Address + 0 Byte 3 . Base Address + 1 Byte 2 . Base Address + 2 Byte 1 . Base Address + 3 Byte 0
Select the output choice for the following set of code:
publicstaticvoid Main(string[] args)
double ZERO =0;
Console.WriteLine("RESULT OF DIVISION BY ZERO IS :{0}", (0/ ZERO));
exception arguement is thrown
NaN
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies