0% found this document useful (0 votes)
12 views3 pages

C# Assingment

The document contains two code snippets in C# that demonstrate boxing and unboxing of an integer value and finding the maximum and minimum values in a 1D integer array.

Uploaded by

suraj nath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

C# Assingment

The document contains two code snippets in C# that demonstrate boxing and unboxing of an integer value and finding the maximum and minimum values in a 1D integer array.

Uploaded by

suraj nath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Date: 7/02/2024

Q1. Create a program in c#.net to perform boxing and unboxing (CO-


1, BL-6).
Solution:
using System;
class Program
{
public static void Main(string[] args)
{
int num = 100;
object b = num;
Console.WriteLine("Boxing :" + b);
int c;
c = (int)b;
Console.WriteLine("Unboxing :" + c);
Console.WriteLine("Created by Suraj Nath");
Console.WriteLine("MCA-II B, Roll No: 76");
Console.ReadKey();

}
}

Output:
Date:13/02/2024
Q3. Create a 1D array in c# which take 5 integer inputs, find the max
and min value in the array (CO-1, BL-6).
Solution:
using System;
class Program
{
public static void Main(string[] args)
{
int[] arr = new int[5] { 8, 9, 12, 13, 5 };
int max = 0;
int min = arr[0];
for (int i = 0; i < 5; i++)
{
if (max < arr[i])
{
max = arr[i];
}
if (min > arr[i])
{
min = arr[i];
}
}
Console.WriteLine("Maximum number is " + max);
Console.WriteLine("Minimum number is " + min);
Console.WriteLine("Created by Suraj Nath");
Console.WriteLine("MCA-II B, Roll No: 76");
Console.ReadKey();
}
}

Output:

You might also like