Dot Net Index & Journal
Dot Net Index & Journal
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 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).
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.
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);
}
}
}
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.
foreach(charchrinstr)
{
l +=1;
}
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");
}
}