adplus-dvertising
frame-decoration

Question

Select error in the given program :
Static Void Main(String[] args)
 {
     const int m = 100;
     int n = 10;
     const int k = n / 5 * 100 * n ;
     Console.WriteLine(m * k);
     Console.ReadLine();
 }

a.

‘k’ should not be declared constant

b.

Expression assigned to ‘k’ should be constant in nature

c.

Expression (m * k) is invalid

d.

‘m ‘ is declared in invalid format

Posted under C# programming

Answer: (b).Expression assigned to ‘k’ should be constant in nature

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Select error in the given program :

Similar Questions

Discover Related MCQs

Q. Arrange the following datatype in order of increasing magnitude sbyte, short, long, int.

Q. Which datatype should be more preferred for storing a simple number like 35 to improve execution speed of a program?

Q. Which Conversion function of ‘Convert.TOInt32()’ and ‘Int32.Parse()’ is efficient?

1) Int32.Parse() is only used for strings and throws argument exception for null string
2) Convert.Int32() used for datatypes and returns directly ‘0’ for null string

Q. Correct way to assign values to variable ‘c’ when int a=12, float b=3.5,int c;

Q. Correct Set of Code for given data ‘a’ and ‘b’ to print output for ‘c’ as 74 ?

Q. Default Type of number without decimal is ?

Q. Select a convenient declaration and initialization of a floating point number:

Q. Number of digits upto which precision value of float datatype is valid ?

Q. Valid Size of float datatype is ?

Q. Correct way to define a value 6.28 in a variable ‘pi’ where value cannot be modified ?

Q. Minimum and Maximum range of values supported by ‘float’ data type are ?

Q. 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.

Q. 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 ?

Q. The Default value of Boolean DataType is ?

Q. Which of the following format specifiers is used to print hexadecimal values and return value of output as Octal equivalent in C# ?

Q. What is the Size of ‘Char’ datatype?

Q. Select the correct differences between char and varchar datatypes?

1. varchar is non unicode and char is unicode character datatype
2. char is ‘n’ bytes whereas varchar is actual length in bytes of data entered in terms of storage size
3. varchar is variable in length and char is the fixed length string
4. For varchar, if a string is less than the maximum length then it is stored in verbatim without any extra characters while for char if a string is less than the set length it is padded with extra characters to equalize its length to given length

Q. Which is the String method used to compare two strings with each other ?

Q. For two strings s1 and s2 to be equal, which is the correct way to find if the contents of two strings are equal ?

Q. Correct statement about strings are ?