Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. What is the output of the following program? namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int p; int[] A =

1. What is the output of the following program?

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

int p;

int[] A = {2,5,6,1,8,4,9,1,3,0};

for (p = 0; p < 10; ++p)

{

if(A[p]%2 == 1)

Console.WriteLine(A[p]);

} Console.ReadLine();

}

}

}

2. What is the output of the following program? [6 Marks]

class Program

{

static void method1(ref int m, int n)

{

m = m + 10;

n = n + 20;

}

static void Main(string[] args)

{

int x = 100;

int y = 50;

method1(ref x, y);

Console.WriteLine("x =" + x);

Console.WriteLine("y =" + y);

Console.ReadLine();

}

}

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

class Program

{

static Main(string[] args)

{

{

/ This is a comment

int m = 12

Console.WriteLine("The value of m = ",);

}

Console.ReadLine();

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

LO2 Compare three types of individual incentives.

Answered: 1 week ago