Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Part I: Theoretical Questions

1. What is Type Casting in C#? Name the two forms of Type Castings in C#. Why is it needed?

2. What are the access modifiers in C#?

3. State the different ways of passing parameters to a method in C#.

4. Does C# support multiple inheritance? Explain how multiple inheritance can be implemented in C# with the help of an example.

5. Consider the following code. Convert the if-else statement to switch-case.

if (opt == 1)
{
result = num1 + num2;
Console.WriteLine("\n{0} + {1} = {2}", num1, num2, result); }
else if (opt == 2)
{
result = num1 - num2;
Console.WriteLine("\n{0} - {1} = {2}", num1, num2, result); }
else if (opt == 3)
{
result = num1 * num2;
Console.WriteLine("\n{0} * {1} = {2}", num1, num2, result);
}
else if (opt == 4)
{
result = (float)num1 / num2;
Console.WriteLine("\n{0} / {1} = {2}", num1, num2, result);
}
else { Console.WriteLine("\nInvalid option.Please try again.");
}

Part II: Output and Debugging Questions

Note: Provide a copy of the code and screen shot for the output in the solutions

1. Consider the program below. Will the program generate an output? If not, why? Write the corrected program.

class Program
{
static void Main(string [] args)
{
const int a = 5;
const int b = 6;
for (int i = 1; i <= 5; i++)
{
a = a * i;
b = b * i;
}
Console.WriteLine(a);
Console.WriteLine(b);
Console.ReadLine();
}
}

2. What is the output of the following program?

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int p, q;
int[,] M = new int[5, 5];
for (p = 0; p < 5; ++p)
{
for (q = 0; q < 5; ++q)
{
M[p, q] = p * 1 + q * 1;
Console.Write(M[p, q] + " ");

} Console.Write("\n");

} Console.ReadLine();

}
}
}

3. Identify the errors in the following C# program. Write the correct program. [4 marks]

class Program
{
static void Main(string[] args)
{
/ This is a comment
integer m=9,
Console.WriteLine("value = ', m);

}
}

Part III- Problem Solving Questions

Note: Provide a copy of the code and screen shot for the output in the solutions

1. Using loops, write a C# program which accepts the number of rows and then prints a pattern according to the number of rows as shown below.

Enter number of rows :6

$
$$
$$$
$$$$
$$$$$

2. Write a C# program to:-
a. Define a two dimensional array of three rows and three columns.
b. Read array elements from the keyboard.
c. Print the array elements.
d. Calculate the sum of diagonal elements and print the sum.

1654_Figure1.jpg

3. Write a C# program to
a. Input a string from the keyboard
b. Print the given string
c. Reverse the string and print it.
d. Print the reversed string in capital letters.

1743_Figure2.jpg

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92035386
  • Price:- $80

Guranteed 48 Hours Delivery, In Price:- $80

Have any Question?


Related Questions in Programming Language

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As