You are on page 1of 3

LAB 04

NAME: GHAZANFAR QARSHI


ROLL NO: 2020-BSCS-019
SEC: A
TASK 01
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
public class Accessors
{
private String courseName;
private string courseCode;

public String nameOfCourse


{
get
{
return courseName;
}
set
{
courseName = value;
}
}
public string codeOfCourse
{
get
{
return courseCode;
}
set
{
courseCode = value;
}
}
}
class Program
{
static void Main(string[] args)
{
Accessors obj = new Accessors();
obj.nameOfCourse = "OOP-Lab";
obj.codeOfCourse = "CS-127";
Console.WriteLine("Course Name: " + obj.nameOfCourse);
Console.WriteLine("Course Code: " + obj.codeOfCourse);
Console.ReadKey();
}
}
}

OUTPUT:

TASK 02
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
class Program
{
public void fact(int number)
{
int result = 1;
while (number != 1)
{
result = result * number;
number = number - 1;
}
Console.WriteLine("The factorial is: " + result);
}
static void Main(string[] args)
{
Program obj = new Program();
obj.fact(5);
Console.ReadKey();

}
}
}

OUTPUT:

You might also like