C Part A 2024-25
C Part A 2024-25
C Part A 2024-25
LAB
SOURCE CODE:
1
PART-A C# AND DOT NET FRAMEWORK
LAB
End If
End If
End Sub
OUTPUT:
2
PART-A C# AND DOT NET FRAMEWORK
LAB
SOURCE CODE:
End Sub
OUTPUT:
5
PART-A C# AND DOT NET FRAMEWORK
LAB
SOURCE CODE:
6
PART-A C# AND DOT NET FRAMEWORK
LAB
End Sub
OUTPUT:
8
PART-A C# AND DOT NET FRAMEWORK
LAB
9
PART-A C# AND DOT NET FRAMEWORK
LAB
SOURCE CODE:
10
PART-A C# AND DOT NET FRAMEWORK
LAB
End Function
Public Function gcd(ByVal a As Integer, ByVal b As Integer) As
Integer
If a < 1 Or b < 1 Then
Throw New ArgumentException("a or b is less than 1")
End If
Dim large As Integer = Math.Max(a, b)
Dim small As Integer = Math.Min(a, b)
Dim r As Integer = 0
Do
r = large Mod small
large = small
small = r
Loop While small <> 0
Return large
End Function
End Class
OUTPUT:
11
PART-A C# AND DOT NET FRAMEWORK
LAB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PartA5
{
class Program
{
static void Main(string[] args)
{
int n, i, m = 0, flag = 0;
Console.Write("Enter the number to check Prime:");
n = int.Parse(Console.ReadLine());
m = n / 2;
for (i = 2; i <= m; i++)
{
if (n % i == 0)
{
if (flag == 0)
{
Console.WriteLine("Number is not Prime:");
Console.WriteLine("The factors are:");
}
Console.WriteLine(i);
flag = 1;
}
}
if (flag == 0)
Console.Write("Number is Prime");
Console.ReadLine();
}
}
12
PART-A C# AND DOT NET FRAMEWORK
LAB
OUTPUT:
13
PART-A C# AND DOT NET FRAMEWORK
LAB
using System;
namespace PartA6
{
class Salary
{
int Empno;
String empname, DOB;
double basic;
public Salary(int eno, string name, string db, double sal)
{
Empno = eno;
empname = name;
DOB = db;
basic = sal;
}
public void display()
{
Console.WriteLine("Empno:"+Empno);
Console.WriteLine("Empname:"+empname);
Console.WriteLine("DOB:"+DOB);
Console.WriteLine("Basic salary:"+basic);
}
public void calculate()
{
14
PART-A C# AND DOT NET FRAMEWORK
LAB
int pt;
double da,hra,pf,gross,net;
if(basic<=20000)
{
da=0.4*basic;
hra=0.10*basic;
gross=basic+da+hra;
pf=0.12*gross;
pt=100;
net=gross-pt-pf;
}
else
{
da=0.5*basic;
hra=0.15*basic;
gross=basic+da+hra;
pf=0.12*gross;
pt=150;
net=gross-pt-pf;
}
Console.WriteLine("DA:"+da);
Console.WriteLine("HRA:"+hra);
Console.WriteLine("pf:"+pf);
Console.WriteLine("Professional Tax:"+pt);
Console.WriteLine("Net:"+net);
Console.WriteLine("Gross:"+gross);
}
static void Main(string[] args)
{
Salary S;
S=new Salary(1,"Akash","21-12-1996",20000.50);
S.display();
S.calculate();
Console.ReadLine();
}
}
15
PART-A C# AND DOT NET FRAMEWORK
LAB
OUTPUT:
16
PART-A C# AND DOT NET FRAMEWORK
LAB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace complex
{
class complex
{
public int real;
public int img;
public complex()
{
real=0;
img=0;
}
public complex(int real,int img)
{
this.real=real;
this.img=img;
}
public static complex operator+(complex ob1,complex ob2)
{
complex temp=new complex();
temp.real=ob1.real+ob2.real;
temp.img=ob1.img+ob2.img;
return temp;
17
PART-A C# AND DOT NET FRAMEWORK
LAB
}
public static complex operator*(complex ob1,complex ob2)
{
complex temp=new complex();
temp.real=(ob1.real*ob2.real)-(ob1.img*ob2.img);
temp.img=(ob1.real*ob2.img)+(ob1.img*ob2.real);
return temp;
}
public void printcomplexNumber()
{
Console.WriteLine("{0}+{1}i", real, img);
}
}
class program
{
static void Main(string[] args)
{
complex c1 = new complex(4, 2);
complex c2 = new complex(2, 3);
complex c3, c4;
c3 = c1 + c2;
c4 = c1 * c2;
Console.WriteLine("c1:");
c1.printcomplexNumber();
Console.Write("c2:");
c2.printcomplexNumber();
Console.WriteLine("The addition of two complex number
is");
Console.Write("c3:");
c3.printcomplexNumber();
Console.WriteLine("The multiplication of two complex
number is");
Console.Write("c4:");
c4.printcomplexNumber();
Console.ReadLine();
}
}
18
PART-A C# AND DOT NET FRAMEWORK
LAB
OUTPUT:
19