Professional Documents
Culture Documents
namespace hello_world
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
Console.ReadLine();
}
}
}
Output:
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
namespace prime
{
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)
{
Console.Write("number is not prime");
flag=1;
break;
}
}
if(flag==0)
Console .Write ("Number is prime");
Console.ReadLine ();
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
}
}
}
Output:
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
namespace Commandline
{
class Program
{
static void Main(string[] args)
{
{
int a,b,c;
a=int.Parse(args[0]);
b=int.Parse(args[0]);
c=a+b;
Console.WriteLine(“the sum is”+c);
Console.ReadLine();
}
}
}
}
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
Output:
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
namespace passby
{
class Program
{
static void Main(string[] args)
{
int a=20;
int b=30;
Console.WriteLine("before swapping");
Console.WriteLine("a=" +a);
Console.WriteLine("b=" +b);
swap(a, b);
Console.WriteLine("after swapping");
Console.WriteLine("a=" +a);
Console.WriteLine("b=" +b);
Console.ReadLine();
}
static void swap(int x,int y)
{
int t;
t=x;
x = y;
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
y = t;
}
}
}
Output:
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
2)Pass By Reference:
Source code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace passby
{
class Program
{
static void Main(string[] args)
{
int a = 20;
int b = 30;
Console.WriteLine("before swapping");
Console.WriteLine("a=" + a);
Console.WriteLine("b=" + b);
swap(ref a, ref b);
Console.WriteLine ("after swapping");
Console.WriteLine("a=" + a);
Console.WriteLine("b=" + b);
Console.ReadLine();
}
static void swap(ref int x,ref int y)
{
int t; t
= x; x
= y; y
= t;
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
}
}
}
Output:
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
int no, sum = 0, rem;
public Form1()
{
InitializeComponent();
}
}
}
}
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
Output:
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
Q.2 Write a program to accept a number from user and display it in reverse order.
Source code:
Output:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace p2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Output:
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
Q.3 Write a program to accept two numbers from user and perform all arithmetic
operation on it.
Source code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int no1, no2, add;
no1 = Int32.Parse(textBox1.Text);
no2 = Int32.Parse(textBox2.Text);
add = no1 + no2;
label3.Text = add.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
int no1, no2, sub;
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
no1 = Int32.Parse(textBox1.Text);
no2 = Int32.Parse(textBox2.Text);
sub = no1 - no2;
label3.Text = sub.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
int no1, no2,mult;
no1 = Int32.Parse(textBox1.Text);
no2 = Int32.Parse(textBox2.Text);
mult = no1 * no2;
label3.Text = mult.ToString();
}
private void button4_Click(object sender, EventArgs e)
{
int no1, no2, div;
no1 = Int32.Parse(textBox1.Text);
no2 = Int32.Parse(textBox2.Text);
div = no1 / no2;
label3.Text = div.ToString();
}
}
}
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
Output:
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
Q.4 Create user registration form insert appropriate fields on it connect with database
and perform insert, update, delete operation on it.
Source code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace lastex
{
public partial class Form1 : Form
{
SqlConnection con;
SqlCommand cmd;
SqlDataReader dr;
public Form1()
{
InitializeComponent();
}
cmd.Parameters.AddWithValue("@Id", textBox1.Text);
cmd.Parameters.AddWithValue("@Name", textBox2.Text);
cmd.Parameters.AddWithValue("@Address", textBox3.Text);
cmd.Parameters.AddWithValue("@Gender", comboBox1 .Text );
cmd.Parameters.AddWithValue("@Email", textBox5.Text);
con.Open();
int res = cmd.ExecuteNonQuery();
if (res == 1)
{
label6.Text = "Data is succesfully submitted";
}
else
{
label6 .Text = "Please enter correct data ";
}
con.Close();
cmd.Parameters.AddWithValue("@Id", textBox1.Text);
cmd.Parameters.AddWithValue("@Name", textBox2.Text);
cmd.Parameters.AddWithValue("@Address", textBox3.Text);
cmd.Parameters.AddWithValue("@Gender", comboBox1.Text);
cmd.Parameters.AddWithValue("@Email", textBox5.Text);
con.Open();
int res = cmd.ExecuteNonQuery();
if (res == 1)
{
label6.Text = "Data is succesfully submitted";
}
else
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
{
label6.Text = "Please enter correct data ";
}
con.Close();
}
else
{
label6.Text = "update is unsuccessfull";
}
}
}
else
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
{
label6.Text = "delete is unsuccessfull";
}
}
}
}
Output:
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
Q.1 Create a webpage as user registration form that consist various server control such
as (Text box, Label, Radiobutton, Checkbox, List and Button. )
Source code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
width: 541px;
}
.style3
{
text-align: center;
}
.style4
{
width: 541px;
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
text-align: right;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="style3">
Registration form
</div>
<div>
<table class="style1">
<tr>
<td class="style4">
Student name</td>
<td>
<asp:TextBox ID="Txtname" runat="server"
ontextchanged="TextBox1_TextChanged"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style4">
Address</td>
<td>
<asp:TextBox ID="Txtadd" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
<td class="style4">
Class</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>select class</asp:ListItem>
<asp:ListItem Value="BCA1"></asp:ListItem>
<asp:ListItem Value="BCA2"></asp:ListItem>
<asp:ListItem Value="BCA3"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style4">
</td>
<td>
</td>
</tr>
<tr>
<td class="style4">
</td>
<td>
</td>
</tr>
<tr>
<td class="style4">
Date Of Birth</td>
<td>
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
 
; &nbs
p; &nb
sp; &n
bsp; &
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
nbsp;
 
;
<asp:Button ID="btnsubmit" runat="server"
onclick="Button1_Click"
Text="SUBMIT" />
</td>
<td>
<asp:Button ID="btncancle" runat="server"
onclick="Button2_Click"
Text="CANCLE" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
Output:
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
text-align: center;
}
.style3
{
text-align: right;
width: 663px;
}
.style4
{
width: 663px;
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="style2">
login form
</div>
<div>
<table class="style1">
<tr>
<td class="style3">
User Id</td>
<td>
<asp:TextBox ID="Txtid" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
Password</td>
<td>
<asp:TextBox ID="txtpass" runat="server"
TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style4">
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
</td>
<td>
</td>
</tr>
<tr>
<td class="style4">
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
 
; &nbs
p; &nb
sp; &n
bsp;
<asp:Button ID="btnlogin" runat="server"
onclick="btnlogin_Click"
Text="Login" />
</td>
<td>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/Reg.aspx">Click Here</asp:HyperLink>
</td>
</tr>
</table>
</div>
</form>
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
</body>
</html>
Output:
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
Q.3 Create a web page user registration page of perform various validation by using
validation control.
Source code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="validation5.aspx.cs"
Inherits="validation5" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
width: 100%;
.style2
width: 455px;
.style3
width: 455px;
text-align: right;
.style4
text-align: center;
width: 1125px;
.style5
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
{
width: 325px;
.style6
width: 455px;
text-align: right;
height: 29px;
.style7
width: 325px;
height: 29px;
.style8
height: 29px;
.style9
width: 455px;
text-align: right;
height: 26px;
.style10
width: 325px;
height: 26px;
.style11
{
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
height: 26px;
.style12
width: 455px;
height: 23px;
.style13
width: 325px;
height: 23px;
.style14
height: 23px;
</style>
</head>
<body>
<div class="style4">
Registration form
<br />
</div>
<div>
<table class="style1">
<tr>
<td class="style3">
Student name</td>
<td class="style5">
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
<asp:TextBox ID="Txtname" runat="server"></asp:TextBox>
</td>
<td>
ForeColor="Red" ValidationGroup="0"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style3">
address</td>
<td class="style5">
</td>
<td>
ForeColor="Red" ValidationGroup="0"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style6">
Email</td>
<td class="style7">
</td>
<td class="style8">
ForeColor="Red"
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
ValidationExpression="^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-
]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style6">
class</td>
<td class="style7">
<asp:ListItem>Select class</asp:ListItem>
<asp:ListItem Value="BCA2"></asp:ListItem>
<asp:ListItem Value="BCA3"></asp:ListItem>
</asp:DropDownList>
</td>
<td class="style8">
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style5">
</td>
<td>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style5">
</td>
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
<td>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style5">
</td>
<td>
</td>
</tr>
<tr>
<td class="style3">
mobile no</td>
<td class="style5">
</td>
<td>
ForeColor="Red" ValidationExpression="[0-9]{10}"
ValidationGroup="0"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style3">
Age</td>
<td class="style5">
</td>
<td>
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
MaximumValue="35" MinimumValue="18"
ValidationGroup="0"></asp:RangeValidator>
</td>
</tr>
<tr>
<td class="style3">
Gender</td>
<td class="style5">
</td>
<td>
</td>
</tr>
<tr>
<td class="style9">
</td>
<td class="style10">
</td>
<td class="style11">
</td>
</tr>
<tr>
<td class="style3">
Hobby</td>
<td class="style5">
<td>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td class="style5">
</td>
<td>
</td>
</tr>
<tr>
<td class="style9">
password</td>
<td class="style10">
</td>
<td class="style11">
</td>
</tr>
<tr>
<td class="style6">
comform password</td>
<td class="style7">
</td>
<td class="style8">
ControlToCompare="Txtpass" ControlToValidate="txtcpass"
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
</td>
</tr>
<tr>
<td class="style12">
</td>
<td class="style13">
</td>
<td class="style14">
</td>
</tr>
<tr>
<td class="style2">
</td>
<td class="style5">
ValidationGroup="0" />
</td>
<td>
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Output
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.
Name:MAHESH LAXMAN MALI Roll No:29
Class:BCA III Sem:V.