0% found this document useful (0 votes)
10 views

net file

Uploaded by

NARENDER
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

net file

Uploaded by

NARENDER
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

INDEX

SR.NO. NAME OF PROGRAMS SIGNATURE


1. Write a program for how to print simple text.
2. Write a program to show a message box with text
inside.
3. Write a program to perform Arithmetic operation.
4. Write a program to calculate simple interest.
5. Write a program to calculate area of some
mathematical figure.
6. Write a program to draw pattern.

7. Working with:
Message Boxes; Dialog Boxes; Menus; Toolbars
8. Write a program to store student information in
database.
9. Working with Web Forms server controls; label;
dropdown list box; Button; AdRotator; Textbox;
Checkbox etc.
10. Write a program to make an admission form.
11. Write a program to convert different types of
variables into string
12. Write a program to implement concept of delegates
on Array List
13. Write a program to implement concept of Jagged
Array
14. Write a program to implement calculator

15. Write a program to demonstrate the join () method


of string class
16. Write a program to create a user-defined function
to add two integers
1. Write a program for how to print simple text.

INPUT:

Module Module1

Sub Main()
Console.WriteLine("Hello World")
Console.ReadLine()
End Sub

End Module

OUTPUT:
2: Write a program to show a message box with text inside.

INPUT:

OUTPUT:
3: Write a program to perform Arithmetic operation.

INPUT:

OUTPUT:

Line 1 - Value of c is 31
Line 2 - Value of c is 11
Line 3 - Value of c is 210
Line 4 - Value of d is 2.1
Line 5 - Value of c is 2
Line 6 - Value of c is 1
Line 7 - Value of c is 100
4: Write a program to calculate simple interest.

INPUT:

Imports System

Public Class Interest

Public Shared Sub simpleInterest(ByVal principle As Double,


ByVal time As Double,
ByVal rate As Double)

Console.WriteLine("Principal : {0}", principle)


Console.WriteLine("Time : {0}", time)
Console.WriteLine("Rate : {0}", rate)

Dim amount As Double = (principle * time * rate) / 100


Console.WriteLine("Simple Interest : {0} "&vbLf, amount)
End Sub
Public Shared Sub Main(ByVal args As String())

simpleInterest(1500, 3, 7.3)
simpleInterest(170.4, 7, 3.4)
End Sub
End Class

OUTPUT:
5: Write a Program to calculate area of some mathematical figure.
INPUT:

'VB.Net program to calculate the area of the rectangle.

Module Module1

Sub Main()

Dim length As Single = 0.0F


Dim breadth As Single = 0.0F
Dim area As Single = 0.0F

Console.Write("Enter the length of rectangle: ")


length = Single.Parse(Console.ReadLine())

Console.Write("Enter the breadth of rectangle: ")


breadth = Single.Parse(Console.ReadLine())

area = length * breadth

Console.WriteLine("Area of ractangle: {0}", area)

End Sub

End Module

OUTPUT:
6: Write a program to draw pattern.
INPUT:

Imports System
Module Module1
Sub Main()
Dim a, b, num As Integer ' initialize the local variable
Console.WriteLine(" Enter the number of rows: ")
num = Console.ReadLine() ' take an input from the user
For a = 1 To num
For b = 1 To a
Console.Write("* ") ' print the star
Next
Console.WriteLine("") ' jump to new line
Next
Console.WriteLine(" Press any key to exit...")
Console.ReadKey()
End Sub
End Module

OUTPUT:
7: Working with:
Message Boxes; Dialog Boxes; Menus; Toolbars

Message Box:
Input:

Output:
Dialog Box:

Input:

Output:
Menus:

Input:

Output:
Toolbar:
Input:

Output:
8:Write a program to store student information in database.
Output:
9:Working with Web Forms server controls; label; dropdown list
box; Button; Textbox; Checkbox

Label and Textbox:


Input:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebControls.as


px.cs"
Inherits="WebFormsControlls.WebControls" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
margin-left: 0px; }
.auto-style3 {
width: 121px; }
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<h4>Provide the Following Details:</h4>
<table class="auto-style1">
<tr>
<td class="auto-style3">
<asp:Label ID="Label1" runat="server" Text="User Name"></asp:Label></td>
<td>
<asp:TextBox ID="TextBox1" runat="server" CssClass="autostyle2">
</asp:TextBox></td>
</tr>
<tr>
<td class="auto-style3">
<asp:Label ID="Label2" runat="server" Text="Upload a File"></asp:Label></td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>

Output:
Button:
Input:

Output:
Code Behind:

Output:
Checkbox:
Input:

Output:
Code behind:

Output:
DropDown List:
Input:

Output:
Code Behind:

Output:
10. Write a program to make an admission form.
<table align="center" class="style1" style="border: thin solid #008080">

<tr>

<td colspan="3"

style="border-bottom: thin solid #008080; font-weight: 700; text-align: center;">

Admission Form</td>

</tr>

<tr>

<td class="style5">

&nbsp;</td>

<td class="style4">

&nbsp;</td>

<td>

&nbsp;</td>

</tr>

<tr>

<td class="style6">

FirstName :

</td>

<td class="style4">

<asp:TextBox ID="txtfname" runat="server" Width="120px"></asp:TextBox>

</td>

<td>

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"

ControlToValidate="txtfname" ErrorMessage="!!" ForeColor="Red"

SetFocusOnError="True"></asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td class="style6">

LastName :
</td>

<td class="style4">

<asp:TextBox ID="txtlname" runat="server" Width="120px"></asp:TextBox>

</td>

<td>

<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"

ControlToValidate="txtlname" ErrorMessage="!!" ForeColor="Red"

SetFocusOnError="True"></asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td class="style6">

City :

</td>

<td class="style4">

<asp:TextBox ID="txtcity" runat="server" Width="120px"></asp:TextBox>

</td>

<td>

<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"

ControlToValidate="txtcity" ErrorMessage="!!" ForeColor="Red"

SetFocusOnError="True"></asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td class="style6">

Email :

</td>

<td class="style4">

<asp:TextBox ID="txtemail" runat="server" Width="120px"></asp:TextBox>

</td>

<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"

ControlToValidate="txtemail" ErrorMessage="!!" ForeColor="Red"

SetFocusOnError="True"></asp:RequiredFieldValidator>

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"

ControlToValidate="txtemail" ErrorMessage="invalid email" ForeColor="Red"

ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*"></asp:RegularExpressionValidator>

</td>

</tr>

<tr>

<td class="style6">

Password&nbsp; :</td>

<td class="style4">

<asp:TextBox ID="txtpassword" runat="server" Width="120px"


TextMode="Password"></asp:TextBox>

</td>

<td>

<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"

ControlToValidate="txtpassword" ErrorMessage="!!" ForeColor="Red"

SetFocusOnError="True"></asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td class="style5">

&nbsp;</td>

<td class="style4">

<asp:Button ID="btnregistration" runat="server" Text="Register"

onclick="btnregistration_Click" />

</td>

<td>

&nbsp;</td>

</tr>
<tr>

<td class="style5">

&nbsp;</td>

<td class="style2" colspan="2">

<asp:Label ID="lblmsg" runat="server"></asp:Label>

</td>

</tr>

<tr>

<td colspan="3">

&nbsp;<asp:GridView ID="GridView1" runat="server">

</asp:GridView>

</td>

</tr>

</table>

The C# code for register button click :

protected void btnregistration_Click(object sender, EventArgs e)

lblmsg.Text = "";

SqlConnection SQLConn = new SqlConnection("Data Source=.\\SQLExpress; Initial Catalog=Blog;


Integrated Security=True");

SqlDataAdapter SQLAdapter = new SqlDataAdapter("insert into UserMst values('" +


txtfname.Text + "','" + txtlname.Text +
"','"+txtcity.Text+"','"+txtemail.Text+"','"+txtpassword.Text+"')", SQLConn);

DataTable DT = new DataTable();

SQLAdapter.Fill(DT);

SqlDataAdapter SQLAAdapter = new SqlDataAdapter("select * from UserMst", SQLConn);

DataTable DTT = new DataTable();


SQLAAdapter.Fill(DTT);

GridView1.DataSource = DTT;

GridView1.DataBind();

lblmsg.Text = "Registration Done!!";

txtfname.Text = "";

txtlname.Text = "";

txtemail.Text = "";

txtcity.Text = "";

txtfname.Focus();

OUTPUT:
11. Write a program to convert different types of variables into
string.
Module Module1
Sub Main()
Dim a As Double = 123456.789
Dim b As Integer = 123
Dim c As Byte = 123
Dim d As Boolean = False

Dim str As String

str = a.ToString()
Console.WriteLine(str)

str = b.ToString()
Console.WriteLine(str)

str = c.ToString()
Console.WriteLine(str)

str = d.ToString()
Console.WriteLine(str)

Console.ReadLine()
End Sub

End Module

OUTPUT:
12.Write a program to implement concept of delegates on Array
List:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Delegates_demo
{
public delegate int Mydelegate(int x,int y);
class sample
{
public static int rectangle(int a, int b)
{
return a * b;
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("My simple Delegate Program");

Mydelegate mdl = new Mydelegate(sample.rectangle);

Console.WriteLine("The Area of rectangle is {0}", mdl(4, 5));

Console.ReadKey();
}
}
}

OUTPUT:
13. Write a program to implement concept of Jagged Array:
using System;

class GFG {

public static void Main()


{

int[][] jagged_arr = new int[4][];

jagged_arr[0] = new int[] {1, 2, 3, 4};


jagged_arr[1] = new int[] {11, 34, 67};
jagged_arr[2] = new int[] {89, 23};
jagged_arr[3] = new int[] {0, 45, 78, 53, 99};

for (int n = 0; n < jagged_arr.Length; n++) {

System.Console.Write("Row({0}): ", n);

for (int k = 0; k < jagged_arr[n].Length; k++) {

System.Console.Write("{0} ", jagged_arr[n][k]);


}
System.Console.WriteLine();
}
}
}

OUTPUT:
14.Write a program to implement calculator
using System;

using System.Text;

using System.Threading.Tasks;

namespace calculator_c_sharp

class Program

static void Main(string[] args)

string value;

do

int res;

Console.Write("Enter first number:");

int num1 = Convert.ToInt32(Console.ReadLine());

Console.Write("Enter second number:");

int num2 = Convert.ToInt32(Console.ReadLine());

Console.Write("Enter symbol(/,+,-,*):");

string symbol = Console.ReadLine();

switch (symbol)

case "+":

res = num1 + num2;

Console.WriteLine("Addition:" + res);

break;

case "-":

res = num1 - num2;

Console.WriteLine("Subtraction:" + res);

break;
case "*":

res = num1 * num2;

Console.WriteLine("Multiplication:" + res);

break;

case "/":

res = num1 / num2;

Console.WriteLine("Division:" + res);

break;

default:

Console.WriteLine("Wrong input");

break;

Console.ReadLine();

Console.Write("Do you want to continue(y/n):");

value = Console.ReadLine();

while (value=="y" || value=="Y");

OUTPUT:
15.Write a program to demonstrate the join()method of string
class:

using System;
public class Demo {
public static void Main(string[] args) {
string[] strArr = {"AB", "BC", "CD", "DE", "EF", "FG", "GH", "IJ" };
Console.WriteLine("String Array...");
foreach(string s in strArr) {
Console.WriteLine(s);
}
string str = string.Join("*", strArr);
Console.WriteLine("Result (after joining) = " + str);
}
}

OUTPUT:
16.Write a program to create a user-defined function to add two
integers:
using System;

class AddTwoNumbers {

//defining function

static int sumOfTwoNumber(int x, int y){

return x+y;

static void Main() {

try{

//declare two variables

int a = 0;

int b = 0;

Console.Write("Enter first number: ");

a = Convert.ToInt32(Console.ReadLine());

Console.Write("Enter second number: ");

b = Convert.ToInt32(Console.ReadLine());

int sum = sumOfTwoNumber(a,b);

Console.WriteLine("Addition of " + a + " and " + b + " is = " + sum);

catch(Exception ex){

Console.WriteLine("Error: " + ex.ToString());

OUTPUT:

You might also like