Lab 2
1.Write a Console application to find factorial of
a given number
using System;
public class Factorial
{
public static void Main(string[] args)
{
int i,fact=1,number;
Console.Write("Enter any Number: ");
number= int.Parse(Console.ReadLine());
for(i=1;i<=number;i++){
fact=fact*i;
}
Console.Write("Factorial of " +number+" is: "+fact);
}
}
2.Write a
Console application to find the given number is Armstrong or not
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Program
{
class Program
{
static void
Main(string[] args)
{
int num, remainder, sum = 0;
Console.Write("Enter
a number : ");
num = int.Parse(Console.ReadLine());
for (int i =
num; i > 0; i = i / 10)
{
remainder = i % 10;
sum = sum + remainder*remainder*remainder;
}
if (sum == num)
{
Console.Write("Entered
number is an Armstrong number.");
}
else
Console.Write("Entered
number is not an Armstrong number.");
Console.ReadLine();
}
}
}
3. Write a
Console application to generate Fibonacci series
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace fibonaci
{
class Program
{
static
void Main(string[] args)
{
int
i, count, f1 = 0, f2 = 1, f3 = 0;
Console.Write("Enter the Limit : ");
count = int.Parse(Console.ReadLine());
Console.WriteLine(f1);
Console.WriteLine(f2);
for
(i = 0; i <= count; i++)
{
f3 = f1 + f2;
Console.WriteLine(f3);
f1 = f2;
f2 = f3;
}
Console.ReadLine();
}
}
}
4. Write a
Console application to find the biggest among two numbers
using System;
class prog
{
public static
void Main()
{
int
a, b;
Console.WriteLine("Enter the Two Numbers : ");
a =
Convert.ToInt32(Console.ReadLine());
b =
Convert.ToInt32(Console.ReadLine());
if (a
> b)
{
Console.WriteLine("{0}
is the Greatest Number", a);
}
else
{
Console.WriteLine("{0} is the Greatest Number ", b);
}
Console.ReadLine();
}
}
Lab 1
1 Write a asp.net program to display date and time using page load event
<script runat="server">
Sub Page_Load
lbl1.Text="The date and time is " & now()
End Sub
</script>
<!DOCTYPE html>
<html>
<body>
<form runat="server">
<h3><asp:label id="lbl1" runat="server"
/></h3>
</form>
</body>
</html>
2.Write a asp.net program to load an image
<!DOCTYPE
html>
<html>
<body>
<form runat="server">
<asp:Image
runat="server"
AlternateText="Error loading an image "
ImageUrl="mku.gif"/>
</form>
</body>
</html>
3.Write a asp.net program to design a button
<script runat="server">
Sub submit(Source As Object, e As EventArgs)
button1.Text="You clicked me!"
End Sub
</script>
<!DOCTYPE html>
<html>
<body>
<form runat="server">
<asp:Button id="button1" Text="Click me!"
runat="server" OnClick="submit" />
</form>
</body>
</html>
4.Write a asp.net program to find days of a week using list box
<script
runat="server">
Sub submit(Sender As Object,e As EventArgs)
mess.Text="You selected " & drop1.SelectedItem.Text
End Sub
</script>
<!DOCTYPE html>
<html>
<body>
<form runat="server">
<asp:ListBox id="drop1" rows="3" runat="server">
<asp:ListItem selected="true">Sunday</asp:ListItem>
<asp:ListItem>Monday</asp:ListItem>
<asp:ListItem>Tuesday</asp:ListItem>
<asp:ListItem>Wednesday </asp:ListItem>
<asp:ListItem>Thursday</asp:ListItem>
<asp:ListItem>Friday</asp:ListItem>
<asp:ListItem>Saturday</asp:ListItem>
</asp:ListBox>
<asp:Button Text="Submit" OnClick="submit"
runat="server" />
<p><asp:label id="mess" runat="server"
/></p>
</form>
</body>
</html>
No comments:
Post a Comment