Professional Documents
Culture Documents
Assignment No. 1
using System;
namespace ConsoleApp2
{
class testclass
{
static void Main(string[] args)
{
System.Console.Write("Hello CIMDR");
System.Console.Write("Welcome To CIMDR");
System.Console.WriteLine("Batch BCA-III 2020-21");
}
}
}
Output:
Assignment No. 2
using System;
namespace ConsoleApp1
{
class first
{
static void Main(string[] args)
{
Console.WriteLine("This is 1st Class");
}
}
class second
{
static void main()
{
Console.WriteLine("This is 2nd Class");
}
}
class third
{
static void main()
{
Console.WriteLine("This is 3rd Class");
}
}
}
Output:
Assignment No. 3
using System;
namespace ConsoleApp4
{
class Program
{
static void square(int a, int b)
{
a = a * a;
b = b * b;
Console.WriteLine(a + " " + b);
}
static void Main(string[] args)
{
int num1 = 5;
int num2 = 6;
Console.WriteLine(num1 + " " + num2);
square(num1, num2);
Console.WriteLine(num1 + " " + num2);
Console.WriteLine("Press Any Key to Exit...");
Console.ReadLine();
}
}
}
Output:
Assignment No. 4
using System;
namespace ConsoleApp5
{
class person
{
public int age;
}
class Program
{
static void square(person a, person b)
{
a.age = a.age * a.age;
b.age = b.age * b.age;
Console.WriteLine(a.age + " " + b.age);
}
static void Main(string[] args)
{
person p1 = new person();
person p2 = new person();
p1.age = 20;
p2.age = 21;
Console.WriteLine(p1.age + " " + p2.age);
square(p1, p2);
Console.WriteLine("Press Any Key to exit...");
Console.ReadLine();
}
}
}
Output :
Assignment No. 5
using System;
namespace ConsoleApp6
{
class implicitCasting
{
static void Main(string[] args)
{
int i = 56;
long l = i;
float f = l;
Console.WriteLine("int value" + i);
Console.WriteLine("float value" + f);
Console.WriteLine("long value" + l);
}
}
}
Output :
using System;
namespace ConsoleApp7
{
class ExplicitCasting
{
static void Main(string[] args)
{
double d = 56.65;
int i = (int)d;
Console.WriteLine("value of i is " + i);
}
}
}
Output :
Assignment No. 6
a) Boxing
using System;
namespace ConsoleApp8
{
class TestBoxing
{
static void Main()
{
int i = 123;
object o = i; // boxing copies the value of i into object o.
i = 456; // Charge the values of i.
//The change in i does not affect the value stored in o.
Output :
b) Unboxing
using System;
namespace ConsoleApp9
{
class TestUnboxing
{
static void Main()
{
int i = 123;
object o=i; // implicit boxing
try
{
int j = (short)o;//attemt to unbox
System.Console.WriteLine("Unboxing OK.");
}
catch (System.InvalidCastException e)
{
System.Console.WriteLine("{0} Error : Incorrect unboxing.",
e.Message);
}
}
}
}
Output:
Assignment No. 7
using System;
namespace ConsoleApp10
{
class Program
{
static void Main(string[] args)
{
string mine = "Forget code";
string referenceType1 = mine ; //Boxing
string valueType = referenceType1; //Unboxing
bool b = true;
Boolean refrenceType2 = b; //Boxing
bool vaslueType2 = refrenceType2; //Unboxing
System.Console.WriteLine(mine);
System.Console.WriteLine(referenceType1);
System.Console.WriteLine(valueType);
System.Console.WriteLine(b);
System.Console.WriteLine(refrenceType2);
System.Console.WriteLine(vaslueType2);
}
}
}
Output :
Assignment No. 8
using System;
namespace ConsoleApp11
{
public class PassingByValues
{
static int a = 4;
static int b = 7;
{
int temp;
temp = a;
a = b;
b = temp;
System.Console.WriteLine("Inside Swap method");
System.Console.WriteLine("a is {0}", a);
System.Console.WriteLine("b is {0}", b);
}
}
}
Output:
b)
using System;
namespace ConsoleApp12
{
class PassByValue
{
static void Main(string[] args)
{
int x = 10;
System.Console.WriteLine("Variable Value Before Calling the Method:
{0}", x);
Multiplication(x);
System.Console.WriteLine("Variable Value After Calling the Method:
{0}", x);
System.Console.WriteLine("Press Enter Key to Exit..");
System.Console.ReadLine();
}
Output :
Assignment No. 9
using System;
namespace ConsoleApp13
{
public class PassongByRefrence
{
static int a = 4;
static int b = 7;
{
System.Console.WriteLine("Before Swapping");
System.Console.WriteLine("a is {0}", a);
System.Console.WriteLine("b is {0}", b);
System.Console.WriteLine("After Swapping");
System.Console.WriteLine("'a is {0}", a);
System.Console.WriteLine("b is {0}", b);
}
}
}
Output:
b)
using System;
namespace ConsoleApp14
{
class PassByRef
{
static void Main(string[] args)
{
int x = 10;
System.Console.WriteLine("Variable Value Befor Calling the Method:
{0}", x);
multiplication(ref x);
System.Console.WriteLine("Variable Value After Calling the Method:
{0}", x);
System.Console.WriteLine("Press Enter Key to Exit..");
}
public static void multiplication (ref int a)
{
a *= a;
System.Console.WriteLine("Variable Value Inside the Method: {0}", a);
}
}
}
Output:
Assignment No. 10
namespace ConsoleApp15
{
class OutKeyword
{
static void Main()
{
int val;
setValue(out val);
System.Console.WriteLine(val);
}
static void setValue(out int i)
{
i = 12;
}
}
}
Output:
namespace ConsoleApp16
{
class Outpara
{
static void Main(string[] args)
{
int x, y;
Multiplication(out x, out y);
System.Console.WriteLine("x value: {0}", x);
System.Console.WriteLine("y value: {0}", y);
System.Console.WriteLine("Press Enter Key to Exit..");
System.Console.ReadLine();
}
public static void Multiplication (out int a, out int b)
{
a = 10;
b = 5;
a *= a;
b *= b;
BCA III SEM V Page 26
Name :-Tanuja Prakash Date.
Class :- BCA-III Sem : V Roll No. : 28
Subject : Lab Course Based On Paper No 505 (Visual Programming)
}
}
}
Output:
Assignment No. 11
using System;
namespace ConsoleApp17
{
public partial class user
{
private string name;
private string location;
public user(string a, string b)
{
this.name = a;
this.location = b;
}
}
public partial class user
{
public void GetUserDetails()
{
System.Console.WriteLine("Name :" + name);
System.Console.WriteLine(" Location : " + location);
}
}
class PartialClasss
{
static void Main(string[] args)
{
user u = new user("Tanuja Date", "sangli");
u.GetUserDetails();
System.Console.WriteLine("\nPress Enter Key to Exit..");
System.Console.ReadLine();
}
}
Output: