QUESTION BANK: INTRODUCTION TO PROGRAMMING (HCS102) 1. a. Compare and contrast unboxing and widening using code snippets b. Write a code snippet to demonstrate an InvalidCastException [8] c. Explain any three applications supported by C# [7] 2. a. Write notes on types literals e. F, D, M, L etc [8] b. An escape character is a character with a special meaning. Comment. [7] c. Write notes on array access using examples 3. a. Write a program that would illustrate the concept of declaration and initialization of value/reference type variables. Use the following literals for initializing the variables. i. A ii. 50 iii. 123456789 iv. 1234567654321 v. True vi. 0.000000345 vii. 1.23e-5 [18] b. Write a program to perform the following tasks: i. Declare two variables x and y as float types variables ii. Declare m as an integer variable iii. Assign the values 75.86 to x and 43.48 to y iv. Assign the sum of x and y to m v. Display the value of m and comment your output [7] 4. a. Develop a program to demonstrate the concepts of boxing and unboxing
b. Compare and contrast jagged and rectangular arrays using code snippets [15] 5. a. Discuss boxing and unboxing in the context of value and reference types [8] b. Explain the switch case statement with the help of an example [9] c. Explain parameter arrays in C# and give rules governing them [8] 6. a. Explain any two conditional statements in C# with suitable examples [9] b. What is short-hand assignment operator? State advantages of using it [6] c. Identify 10 character escape sequences available in C# with the aid of code snippets (comment your code) 7. a. Write a program using the for statement and demonstrate the effect of the continue and break statement in each case [15] b. Comment of the use of the keywords void, public and static in Main method declaration 8. a. Compare and contrast equality and assignment operators in C# in relation with the if statement b. Define an operator and comment on the concept of precedence and associativity [5] c. Compare and contrast conditional AND and conditional OR using code snippets 9. a. How do we evaluate expressions using post (incrementing/decrementing) and pre (incrementing/decrementing) using examples b. What is a ternary operator and how is it evaluated? What are its strengths or weaknesses in relation to the if else statement [15] 10. Identify 5 jumping/branching statements in C# and explain them using code snippets [25] 11.
a. Compare and contrast do/do-while loop with the while statement [15] b. Compare and contrast the for and the foreach statement 12. a. Define identifiers in C# and rules that govern their naming using code snippets b. Define keywords and contextual keywords in C# with the aid of code snippets [15] 13. Write a program of your choice while implementing standard numeric format specifiers. Use comments [25] 14. a. How many types of comments are supported in C# and justify their rationale [7] b. A variable is a location in memory where a value can be stored for use by a program. Justify c. Which operator(s) is/are used to check (or uncheck) stack overflows during program execution. Use code snippets to support your answer [8] 15. Define the following keywords in the.net 16. 17. a. CLR b. MSIL c. CTS d. Managed code e. Virtual Object System a. Write notes on the process of promotion and narrowing using examples b. C# is a modern language. Justify using code snippets c. C# is a component-based language. Discuss [5] a. Explain jagged arrays. How are they different from rectangular arrays? b. What are checked and unchecked operators? Give an example [8]
c. Explain parameter arrays in C#. Give three restrictions in declaring parameter arrays [7] 18. a. Explain the for loop and while loop with proper syntax and examples [8] b. C# is modern type-safe, versionable and interoperable language. Justify [12] c. When do we use the break and continue statement inside a while loop [5] 19. a. What are jagged arrays? Discuss the syntax of creation and initialization of jagged arrays [8] b. How do you get formatted output using System.Console.WriteLine() method? Describe Integer and currency numeric formatting [6] c. Define a method and explain them with respect to passing parameters by value and by reference [11] 20. a. Explain simple if and nested if conditional statements with suitable examples [8] b. Write short notes on exception handling in C# [6] c. Write a program to implement the use of checked and unchecked operators in try catch block [11] 21. a. C# is a type-safe language. Comment [5] b. What is a CLR? Explain the role of CLR in the.net framework? [5] c. What is Mixed mode arithmetic expression? How is it evaluated? [5] d. How does the foreach statement differ from the for statement? Give a typical example where a foreach statement is used. 22. a. Write a program that would print the value 123.6759 in fixed-point format (use two different methods in each case) with the following specifications: i. Correct to two decimal places ii. Correct to zero decimal places [12]
b. When can the if statement be suitable than the switch statement (vice-versa) using examples [13] 23. a. Describe the following keywords using code snippets: i. dynamic ii. object iii. var [15] b. Write a program which solves a pair of simultaneous equation 24. Write a program which solves a sum of series in the form: a. n+2n+3n+ kn b. 1 2 +2 2 +3 2 + n 2 c. 2 2 +4 2 +6 2 + n 2 d. 1 2 +3 2 +5 2 + n 2 e. 1! +2! +3! + n! f. 1+2+3+ n g. 1+3+5+ n *and then rewrite the program so that you solve the sum of series with any lower limit and upper limit