0% found this document useful (0 votes)
39 views12 pages

Dot Net Index & Journal

The document provides 15 programming problems related to .NET frameworks. The problems cover topics like checking if a string is a palindrome, counting words in a sentence, displaying multiplication tables, swapping variable values, finding sums and factorials, storing employee data to a database and displaying it in a grid, and creating menus that change form properties.

Uploaded by

anuragnair420
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)
39 views12 pages

Dot Net Index & Journal

The document provides 15 programming problems related to .NET frameworks. The problems cover topics like checking if a string is a palindrome, counting words in a sentence, displaying multiplication tables, swapping variable values, finding sums and factorials, storing employee data to a database and displaying it in a grid, and creating menus that change form properties.

Uploaded by

anuragnair420
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/ 12

604 Dot Net Frameworks

Sr.
No. Description Remark
Write a VB.NET program to check whether enter string is
1
palindrome or not.
Write a VB.NET program to accept sentences in text box andcount the
2 number of words and display the count in message
box.
Write a VB.NET program to accept a number from user throughinput
3 box and display its multiplication table into the list box.
Write a program in C# to create a function to swap the values oftwo
4
integers.

Write a program in C# .Net to create a function for the sum oftwo


5
numbers.
Write a program in C#.Net to create a recursive function to findthe
6
factorial of a given number

Write a VB.Net program to accept the details of Employee (ENO, EName


7 Salary) and store it into the database and displayit on grid view control.

Write a Vb.net program to design the following form; it contains the three
menus Color (Red, Blue, and Green), Window (Maximize, Minimize, and
Restore) and Exit. On Selection of any menu or submenu result should
affect the form control( for example if user selected Red color from Color
menu back color of form should get changed to Red and if user selected
8 Maximize from Window Menu then form should get
maximized).

9 Write a c#.Net program for multiplication of matrices.

Write a ASP.Net program to create a Login form which adds


10
Username and Password in the database.
Write a program in C#.Net to find the sum of all elements of thearray.
11

Write a C#.Net application to display the vowels from a givenString.


12

Write a program in C# to create a function to display the n termsof


13
Fibonacci sequence.
14 Write C#.Net to find the length of a string.

15 Write C# program to print individual character from a string.


1) Write a VB.NET program to check whether entered string is palindrome or not.
Public Class DateTimepker
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
txtday.Text = DateTimePicker1.Value.Day txtmonth.Text =
DateTimePicker1.Value.Month txtyear.Text= DateTimePicker1.Value.Year
End Sub
End Class

2) Write a VB.NET program to accept sentences in text box and count the number of
words and display the count in message box.

Public Class CountWords


Dim n, i, cnt As Integer Dim a(30) As Char
Private Sub btncount_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btncount.Click i = 1
n = TextBox1.TextLength
cnt = 0
While i < n
a (i) = TextBox1.Text(i)
If Char.IsWhiteSpace(a(i)) Then
cnt = cnt+ 1
End If
i=i+1
End While
cnt = cnt + 1
MsgBox("Number of Words are:" + Convert.ToString(cnt))
End Sub
End Class
3) Write a VB.NET program to accept a number from user through input box and
display its multiplication table into the list box.

Public Class MultiplTable Dim n, i,


ans As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
i=1
ans = 1
n = InputBox("Enter Number:")
While i <= 10
ans = n * i ListBox1.Items.Add(ans) i = i + 1
End While
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
ListBox1.Items.Clear()
End Sub
End Class

4) Write a program in C# to create a function to swap the values of two integers.

using System;
public class funcexer6
{ public static void interchange(ref int num1, ref int num2)
{
int newnum;
newnum = num1;
num1 = num2;
num2 = newnum;
}
public static void Main(){
int n1,n2;
Console.Write("\n\nFunction:Toswapthevaluesoftwo integer numbers :\n");
Console.Write("----------------------------------------------------------\n");
Console.Write("Enter a number:");
n1= Convert.ToInt32(Console.ReadLine());
Console.Write("Enter another number: ");
n2= Convert.ToInt32(Console.ReadLine()); interchange( ref 1, ref n2);
Console.WriteLine( "Nowthe1stnumberis:{0},andthe 2nd number is : {1}", n1, n2); } }
5) Write a program in C# .Net to create a function for the sum of two numbers.
using System;
namespace Add{
public class Program{
public static int addition(int a, int b){ return (a+b);
}
public static void main(){
int a,b;
int sum;
Console.Write("Enter first number: ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter second number: ");
b = Convert.ToInt32(Console.ReadLine()); sum =
addition(a,b); Console.WriteLine("Sum is: " + sum);

}
}
}

6) Write a program in C#.Net to create a recursive function to find the factorial of a


given number.
usingSystem;
class funcexer11
{
static void Main()
{
decimal f;
Console.Write("\n\nRecursiveFunction : Tofindthefactorial of a given number:\n");
Console.Write(" -----------------------------------------------------------------------\n");
Console.Write("Input a number :");
int num= Convert.ToInt32(Console.ReadLine()); f = Factorial(num);
Console.WriteLine("The factorial of {0}! is {1}", num,f);
}
static decimal Factorial(int n1)
{
if(n1 == 0)
{ return 1; }
else
{
return n1 * Factorial(n1 - 1);
}
}
}
7) Write a VB.Net program to accept the details of Employee (ENO, EName
Salary) and store it into the database and display it on gridview control.
Imports System.Data.OleDb
Imports System.Data
Public Class Form1
PrivateSubForm1_Load(ByValsender AsSystem.Object,ByValeAs System.EventArgs)
Handles
MyBase.Load
DataSet21.Clear()
Me.OleDbDataAdapter1.Fill(DataSet21, "Emp")
End Sub
Private Sub btnfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnfirst.Click
Me.BindingContext(DataSet21, "Emp").Position=0
End Sub
PrivateSubbtnprev_Click(ByValsender AsSystem.Object,ByValeAs
System.EventArgs) Handles btnprev.Click
Me.BindingContext(DataSet21, "Emp").Position = Me.BindingContext(DataSet21,
"Emp").Position-1
End Sub
PrivateSubbtnnext_Click(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs) Handles btnnext.Click
Me.BindingContext(DataSet21, "Emp").Position = Me.BindingContext(DataSet21,
"Emp").Position+1
End Sub
PrivateSubbtnlast_Click(ByValsender AsSystem.Object,ByValeAs
System.EventArgs) Handles btnlast.Click
Me.BindingContext(DataSet21, "Emp").Position = Me.BindingContext(DataSet21,
"Emp").Count - 1
End Sub
Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnsearch.Click
'Me.OleDbDataAdapter1.Fill(Me.DataSet11.Pat) Dim dv
AsNew DataView(DataSet21.Tables("Emp"))
DataGridView1.DataSource = dv
End Sub End Class
8) Write a Vb.net program to design the following form; it contains the three menus
Color (Red, Blue, and Green), Window (Maximize, Minimize, and Restore) and
Exit. On Selection of any menu or submenu result should affect the form control
(for example if user selected Red color from Color menu back color of form
should get changed to Red and if user selected Maximize from Window Menu
then form should get maximized).
Public Class menuprg
Private Sub RedToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RedToolStripMenuItem.Click
Me.BackColor = Color.Red
End Sub

Private Sub GreenToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles GreenToolStripMenuItem.Click
Me.BackColor = Color.Green
End Sub

Private Sub BlueToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles BlueToolStripMenuItem.Click
Me.BackColor = Color.Blue
End Sub

Private Sub NormalToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
NormalToolStripMenuItem.Click
Me.WindowState = FormWindowState.Normal
End Sub

Private Sub MinimisedToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles MinimisedToolStripMenuItem.Click
Me.WindowState = FormWindowState.Minimized
End Sub

Private Sub MaximisedToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles MaximisedToolStripMenuItem.Click
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub

Private Sub RedToolStripMenuItem1_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
RedToolStripMenuItem1.Click
Me.BackColor = Color.Red
End Sub
Private Sub GreenToolStripMenuItem1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
GreenToolStripMenuItem1.Click
Me.BackColor = Color.Green
End Sub

Private Sub BlueToolStripMenuItem1_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
BlueToolStripMenuItem1.Click
Me.BackColor = Color.Blue
End Sub

Private Sub NormalToolStripMenuItem1_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
NormalToolStripMenuItem1.Click
Me.WindowState = FormWindowState.Normal
End Sub

Private Sub MinimumToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
MinimumToolStripMenuItem.Click
Me.WindowState = FormWindowState.Minimized
End Sub

Private Sub MaximumToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
MaximumToolStripMenuItem.Click
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub ExitToolStripMenuItem1_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
ExitToolStripMenuItem1.Click
End
End Sub

Private Sub menuprg_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Me.Click
If MouseButtons.Right = Windows.Forms.MouseButtons.Right Then
ContextMenuStrip1.Show()
End If
End Sub
End Class
9) Write a c#.Net program for multiplication of matrices.
using System;
public class Exercise21
{
public static voidMain()
{
int i,j,k,r1,c1,r2,c2,sum=0;
int[,] arr1 = new int[50,50]; int[,] brr1 =
new int[50,50]; int[,]crr1=new int[50,50];

Console.Write("\n\nMultiplicationoftwoMatrices\n");
Console.Write(" ------------------------------------------------------------------------ \n");
Console.Write("\nInputthenumberofrowsandcolumnsofthe first matrix :\n");
Console.Write("Rows : ");
r1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Columns :");
c1 =Convert.ToInt32(Console.ReadLine());
Console.Write("\nInputthenumberofrowsofthesecondmatrix:\n");
Console.Write("Rows : ");
r2 = Convert.ToInt32(Console.ReadLine()); Console.Write("Columns :");
c2 =Convert.ToInt32(Console.ReadLine());

if(c1!=r2){
Console.Write("MutiplicationofMatrixisnotpossible.");
Console.Write("\nColumnoffirst matrixandrowofsecond matrix must besame.");
}
else
{
Console.Write("Input elementsin the first matrix :\n"); for(i=0;i<r1;i++)
{

for(j=0;j<c1;j++)
{
Console.Write("element-[{0}],[{1}]:",i,j); arr1[i,j] =
Convert.ToInt32(Console.ReadLine());
}
}
Console.Write("Input elements in the second matrix :\n"); for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
{
Console.Write("element-[{0}],[{1}]:",i,j); brr1[i,j] =
Convert.ToInt32(Console.ReadLine());
}
}
Console.Write("\nTheFirst matrixis :\n"); for(i=0;i<r1;i++)
{
Console.Write("\n");
for(j=0;j<c1;j++)
Console.Write("{0}\t",arr1[i,j]);
}

Console.Write("\nTheSecondmatrixis:\n"); for(i=0;i<r2;i++)
{
Console.Write("\n"); for(j=0;j<c2;j++)
Console.Write("{0}\t",brr1[i,j]);
}

//multiplicationofmatrix
for(i=0;i<r1;i++)
for(j=0;j<c2;j++) crr1[i,j]=0;
for(i=0;i<r1;i++) //row of first matrix
{
for(j=0;j<c2;j++) //columnofsecond matrix
{
sum=0;
for(k=0;k<c1;k++)
sum=sum+arr1[i,k]*brr1[k,j]; crr1[i,j]=sum;
}
}
Console.Write("\nThe multiplication of two matrix is : \n"); for(i=0;i<r1;i++)
{
Console.Write("\n"); for(j=0;j<c2;j++)
{
Console.Write("{0}\t",crr1[i,j]);
}
}
}
Console.Write("\n\n");
}
}
10) Write a ASP.Net program to create a Login form which adds Username and
Password in the database.
private void DrawCircleButton_Click(object sender, RoutedEventArgse)
{
try{
string uid = TextBox1.Text
string pass =TextBox2.Text;
con.open
stringqry="select*fromUloginwhereUserId='"+uid+"' and Password='" + pass +"'";
SqlCommand cmd = new SqlCommand(qry,con);
SqlDataReader sdr =cmd.ExecuteReader();
If(sdr.Read())
{
Label4.Text=”Login Sucessful!!!”
}
else
{
Label4.Text=”User Id and Password is not correct. Try Again”
}
con.Close();
catch(Exception ex)

Response.Write(ex.Message);
}}
11) Write a program in C#.Net to find the sum of all elements of the array.
using System;
publicclassExercise3
{
publicstaticvoidMain()
{
int[] a=newint[100];
inti, n, sum=0;
Console.Write("\n\nFind sum of all elements of array:\n");
Console.Write("--------------------------------------\n");
Console.Write("Input the number of elements to be stored in the array :");
n =Convert.ToInt32(Console.ReadLine());
Console.Write("Input {0} elements in the array :\n",n);
for(i=0;i<n;i++)
{
Console.Write("element - {0} : ",i);
a[i]= Convert.ToInt32(Console.ReadLine());
}
for(i=0;i<n;i++){
sum+= a[i];}
Console.Write("Sum of all elements stored in the array is :{0}\n\n", sum);}}
12) Write a C#.Net application to display the vowels from a given String.

string vowels = "aeiou";


stringstr = textBox1.Text;
char[] ch = str.ToCharArray();
foreach (char c in ch)
{
if (vowels.Contains(c.ToString()))
{
Response.Write("vowels :-" + c.ToString() + "<br/>");
}
else
{
Response.Write("consonant :- " + c.ToString() + "<br/>"); //consonant
}
}

13) Write a program in C# to create a function to display the n terms of Fibonacci


sequence.
using System;
public class FibonacciExample
{
public static void Main(string[] args)
{
int n1=0,n2=1,n3,i,number;
Console.Write("Enter the number of elements: ");
number = int.Parse(Console.ReadLine());
Console.Write(n1+" "+n2+" "); //printing 0 and 1
for(i=2;i<number;++i) //loop starts from 2 because 0 and 1 are already printed
{
n3=n1+n2;
Console.Write(n3+" ");
n1=n2;
n2=n3;
}
} }
14) Write C#.Net program to find the length of a string
using System;
publicclassExercise2
{
publicstaticvoidMain()
{
stringstr;/* Declares a string of size 100 */
int l=0;

Console.Write("\n\nFind the length of a string :\n");


Console.Write("---------------------------------\n");
Console.Write("Input the string : ");
str=Console.ReadLine();

foreach(charchrinstr)
{
l +=1;
}

Console.Write("Length of the string is : {0}\n\n", l);


}
}

15) Write C# program to print individual character from a string


publicclassExercise4
{
publicstaticvoidMain()
{
stringstr;
int l=0;

Console.Write("\n\nprint individual characters of string in reverse order :\n");


Console.Write("--------------------------------------------\n");
Console.Write("Input the string : ");
str=Console.ReadLine();

l =str.Length-1;
Console.Write("The characters of the string in reverse are : \n");
while(l >=0)
{
Console.Write("{0} ",str[l]);
l--;
}
Console.Write("\n\n");
}
}

You might also like