C# LAB
MANUAL
PART-A
1.HTML basic tags.
<html>
<head>
<title>The Basic Building Block of HTML</title>
<h2>The Building Block</h2>
</head>
<body>
<p>This is A Paragraph Tag</p>
</body>
</html>
2.HTML text formats.
<html>
<body>
<p>
Example for <b>Bold Text</b><br>
Example for <strong>Important Message</strong><br>
Example for <i>Italic Text</i><br>
Example for <em>Emphasized Text</em><br>
Example for <mark>Marked Text</mark><br>
<small>Smaller Text</small><br>
<del>Deleted Text</del><br>
<ins>Inserted Text</ins><br>
<sub>Subscript Text</sub><br>
<sup>Superscript Text</sup><br>
</p>
</body>
</html>
3.HTML pre-tags.
<!DOCTYPE html>
<html>
<head>
<title>Pre Tag in HTML</title>
</head>
<body>
<pre>
I'm Pursing My Under Graduate
in Nrupathunga University
Bengaluru
</body>
</html>
4.HTML text formatting, horizontal and break tags.
<html>
<head>
<title>Sample</title>
</head>
<body>
<b>Ravichandran</b><br>
<hr/>
<b><i>BCA Student</i></b><br>
<hr/>
<u>Student of Nrupathunga University</u><br>
<hr/>
<p>
Chemical Formula for Sulphuric Acide is
H<sub>2</sub>SO<sub>4</sub><br>
<hr/>
Me and My Friends have planned for a hangout on 1<sup>st</sup> of July
to Ladaak<br>
<hr/>
He is not my <s>Enemy</s><br>
<hr/>
Mandya is Small Town <big><b>Compared to Mysore</b></big><br>
<hr/>
Mysore is Big Town <small><b>Compared to Mandya</b></small><br>
<hr/>
</body>
</html>
5.C# sum of 2 numbers.
using System;
class Program
{
static void Main(string[] args)
{
int a;
int b;
int c;
Console.WriteLine("Enter Two Numbers");
a=int.parse(Console.ReadLine());
b=int.parse(Console.ReadLine());
c=a+b;
Console.WriteLine("The Sum is {0}"+c);
Console.ReadKey();
}
}
6.C# largest of 3 numbers.
using System;
class Program
{
static void Main(string[] args)
{
int a;
int b;
int c;
Console.WriteLine("Enter Two Numbers");
a=int.parse(Console.ReadLine());
b=int.parse(Console.ReadLine());
c=int.parse(Console.ReadLine());
if(a>b && a>c) then
Console.WriteLine("The Largest Number is {0}",a);
else
if(b>c)
Console.WriteLine("The Largest Number is {0}",b);
else
Console.WriteLine("The Largest Number is {0}",c);
Console.ReadKey();
}
}
7.C# factorial of a number.
using System;
class Program
{
static void Main(string[] args)
{
int i,n;
long f=1;
Console.WriteLine("Enter a Numbers");
n=int.parse(Console.ReadLine());
for(i=1;i<=n;i++)
f=f*i;
Console.WriteLine("The Factorial of {0} is {0}",n,f);
Console.ReadKey();
}
}
8.VB.Net loop control statements.
Module Module1
Sub Main()
Console.WriteLine("The Number Starts from 1 to 10"& vbCrLf)
For i As Integer = 1 To 10 Step 1
Console.WriteLine(Number is{0}",i)
Next
Console.WriteLine("Press any Key to Exit...")
Console.ReadKey()
End Sub
End Module
9.VB.Net display message.
Module Module1
Sub Main()
Dim message As String
Console.WriteLine("Enter Message")
message=Console.ReadLine()
Console.WriteLine()
Console.WriteLine("Your Message:{0}",message)
Console.ReadKey()
End Sub
End Module
10.VB.Net even or odd.
Module Module1
Sub Main()
Dim num As Integer = 0
Console.WriteLine("Enter number: ")
num = Integer.Parse(Console.ReadLine())
If num Mod 2 = 0 Then
Console.WriteLine("Given number is EVEN")
Else
Console.WriteLine("Given number is ODD")
End If
Console.ReadKey()
End Sub
End Module
PART-B
11.VB.Net area of circle.
Module Module1
Sub Main()
Dim radius As Single = 0.0F
Dim area As Single = 0.0F
Console.Write("Enter the radius:")
radius = Single.Parse(Console.ReadLine())
area = 3.14F * radius * radius
Console.WriteLine("Area of Circle: {0}", area)
Console.ReadKey()
End Sub
End Module
12.VB.Net check leap year or not.
Module Module1
Sub Main()
Dim year As Integer
Console.WriteLine("Enter Year");
If((year Mod 4=0) AndAlso (year Mod <> 0)) orElse ((year Mod 4=0)
AndAlso
(year Mod 100=0) AndAlso (year Mod 400=0)) Then
Console.WriteLine("Given Year is a Leap Year");
Else
Console.WriteLine("Given Year is Not a Leap Year");
Console.ReadKey();
End Sub
End Module
13.VB.Net sum of digit.
Module Module1
Sub Main()
Dim a, n, sum As Integer
a = 123
sum = 0
While a > 0
n = a Mod 10
sum = sum + n
a = a / 10
End While
Console.WriteLine("Sum of digit is: " & sum)
CConsole.ReadKey()
End Sub
End Module
14.C# palindrome or not.
using System;
class Palindrome
{
public int palindrom(int a)
{
int rev=0,rem;
while(a!=0)
{
rem=a%10;
rev=rev*10+rem;
a=a/10;
}
return rev;
}
public static void Main(string[] args)
{
Palindrome p = new Palindrome();
Console.WriteLine("Enter the Number");
int n=int.Parse(Console.ReadLine());
int temp=p.palindrom(n);
if(temp==n)
Console.WriteLine("Given Number is Palindrome");
else
Console.WriteLine("Given Number is Not Palindrome");
Console.ReadKey();
}
}
15.C# threading.
using System;
using System.Threading;
public class MyThread
{
public void Thread1()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine(i);
}
}
}
public class ThreadExample
{
public static void Main()
{
MyThread mt = new MyThread();
Thread t1 = new Thread(new ThreadStart(mt.Thread1));
Thread t2 = new Thread(new ThreadStart(mt.Thread1));
t1.Start();
t2.Start();
}
}
16.C# square of a number.
using System;
class Program
{
public int square(int nmbr)
{
int sq = nmbr * nmbr;
return sq;
}
public static void Main(string[] args)
{
Program pr = new Program();
int rslt = pr.square( 2);
Console.WriteLine("Square of the given number is "+ rslt);
}
Console.ReadKey();
}
17.C# get length of array.
using System;
class Program
{
static void Main()
{
int[] arrayA = new int[5];
int lengthA = arrayA.Length;
Console.WriteLine("Length of ArrayA : {0}", +lengthA);
long longLength = arrayA.LongLength;
Console.WriteLine("Length of the LongLength Array : {0}",longLength);
int[,] twoD = new int[5, 10];
Console.WriteLine("The Size of 2D Array is : {0}",twoD.Length);
Console.ReadKey();
}
}
18.C# bubble sort.
using System;
class bubblesort
{
static void Main(string[] args)
{
int[] a = { 3, 2, 5, 4, 1 };
int t;
Console.WriteLine("The Array is : ");
for (int i = 0; i < a.Length; i++)
{
Console.WriteLine(a[i]);
}
for (int j = 0; j <= a.Length - 2; j++)
{
for (int i = 0; i <= a.Length - 2; i++)
{
if (a[i] > a[i + 1])
{
t = a[i + 1];
a[i + 1] = a[i];
a[i] = t;
}
}
}
Console.WriteLine("The Sorted Array :");
foreach (int aray in a)
Console.Write(aray + " ");
Console.ReadKey();
}
}