C# LAB
MANUAL
PART-A
[Link] 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>
[Link] 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>
[Link] 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>
[Link] 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;
[Link]("Enter Two Numbers");
a=[Link]([Link]());
b=[Link]([Link]());
c=a+b;
[Link]("The Sum is {0}"+c);
[Link]();
}
}
6.C# largest of 3 numbers.
using System;
class Program
{
static void Main(string[] args)
{
int a;
int b;
int c;
[Link]("Enter Two Numbers");
a=[Link]([Link]());
b=[Link]([Link]());
c=[Link]([Link]());
if(a>b && a>c) then
[Link]("The Largest Number is {0}",a);
else
if(b>c)
[Link]("The Largest Number is {0}",b);
else
[Link]("The Largest Number is {0}",c);
[Link]();
}
}
7.C# factorial of a number.
using System;
class Program
{
static void Main(string[] args)
{
int i,n;
long f=1;
[Link]("Enter a Numbers");
n=[Link]([Link]());
for(i=1;i<=n;i++)
f=f*i;
[Link]("The Factorial of {0} is {0}",n,f);
[Link]();
}
}
[Link] loop control statements.
Module Module1
Sub Main()
[Link]("The Number Starts from 1 to 10"& vbCrLf)
For i As Integer = 1 To 10 Step 1
[Link](Number is{0}",i)
Next
[Link]("Press any Key to Exit...")
[Link]()
End Sub
End Module
[Link] display message.
Module Module1
Sub Main()
Dim message As String
[Link]("Enter Message")
message=[Link]()
[Link]()
[Link]("Your Message:{0}",message)
[Link]()
End Sub
End Module
[Link] even or odd.
Module Module1
Sub Main()
Dim num As Integer = 0
[Link]("Enter number: ")
num = [Link]([Link]())
If num Mod 2 = 0 Then
[Link]("Given number is EVEN")
Else
[Link]("Given number is ODD")
End If
[Link]()
End Sub
End Module
PART-B
[Link] area of circle.
Module Module1
Sub Main()
Dim radius As Single = 0.0F
Dim area As Single = 0.0F
[Link]("Enter the radius:")
radius = [Link]([Link]())
area = 3.14F * radius * radius
[Link]("Area of Circle: {0}", area)
[Link]()
End Sub
End Module
[Link] check leap year or not.
Module Module1
Sub Main()
Dim year As Integer
[Link]("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
[Link]("Given Year is a Leap Year");
Else
[Link]("Given Year is Not a Leap Year");
[Link]();
End Sub
End Module
[Link] 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
[Link]("Sum of digit is: " & sum)
[Link]()
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();
[Link]("Enter the Number");
int n=[Link]([Link]());
int temp=[Link](n);
if(temp==n)
[Link]("Given Number is Palindrome");
else
[Link]("Given Number is Not Palindrome");
[Link]();
}
}
15.C# threading.
using System;
using [Link];
public class MyThread
{
public void Thread1()
{
for (int i = 0; i < 10; i++)
{
[Link](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));
[Link]();
[Link]();
}
}
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 = [Link]( 2);
[Link]("Square of the given number is "+ rslt);
}
[Link]();
}
17.C# get length of array.
using System;
class Program
{
static void Main()
{
int[] arrayA = new int[5];
int lengthA = [Link];
[Link]("Length of ArrayA : {0}", +lengthA);
long longLength = [Link];
[Link]("Length of the LongLength Array : {0}",longLength);
int[,] twoD = new int[5, 10];
[Link]("The Size of 2D Array is : {0}",[Link]);
[Link]();
}
}
18.C# bubble sort.
using System;
class bubblesort
{
static void Main(string[] args)
{
int[] a = { 3, 2, 5, 4, 1 };
int t;
[Link]("The Array is : ");
for (int i = 0; i < [Link]; i++)
{
[Link](a[i]);
}
for (int j = 0; j <= [Link] - 2; j++)
{
for (int i = 0; i <= [Link] - 2; i++)
{
if (a[i] > a[i + 1])
{
t = a[i + 1];
a[i + 1] = a[i];
a[i] = t;
}
}
}
[Link]("The Sorted Array :");
foreach (int aray in a)
[Link](aray + " ");
[Link]();
}
}