Practical Practice Questions
Practical Practice Questions
2) Write a Vb.Net program to move the Text “Pune University” continuously from Left
to Right and Vice Versa.
3) 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);
}} }
4) Write a VB.NET program to accept a character from keyboard and check whether it
is vowel or consonant. Also display the case of that character.
Public Class VowelCheck
5) Design a VB.net form to pick a date from DateTimePicker Control and display day, month
and year in separate text boxes.
Public Class DateTimepker
Console.Write("\nInput the number of rows and columns of the first matrix :\n");
Console.Write("Rows : ");
r1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Columns : ");
c1 = Convert.ToInt32(Console.ReadLine());
if(c1!=r2){
Console.Write("Mutiplication of Matrix is not possible.");
Console.Write("\nColumn of first matrix and row of second matrix must be same.");
}
else
{
Console.Write("Input elements in 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("\nThe First matrix is :\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("\n\n");
Console.Write("Calculate the total, percentage and division to take marks of three
subjects:\n");
Console.Write("------------------------------------------------");
Console.Write("\n\n");
total = phy+che+ca;
per = total/3.0;
if (per>=60)
div="First";
else
if (per<60&&per>=48)
div="Second";
else
if (per<48&&per>=36)
div="Pass";
else
div="Fail";
Imports System.Data.OleDb
Imports System.Data
Public Class Form1
11) 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
12) Write a VB.NET program to create player table (PID, PName, Game, no_of_matches). Insert
records and update number of matches of ‘Rohit Sharma’ and display result in data grid view.
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDbConnection("Provider = MICROSOFT.JET.OLEDB.4.0;data
Source=D:\sym\VB.NET\Player.mdb")
Dim cmd As New OleDbCommand
Dim ad As New OleDbDataAdapter
Dim ds As New DataSet
newnum = num1;
num1 = num2;
num2 = newnum;
}
public static void Main()
{
int n1,n2;
Console.Write("\n\nFunction : To swap the values of two 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 n1, ref n2 );
Console.WriteLine( "Now the 1st number is : {0} , and the 2nd number is : {1}", n1,
n2 );
}
}
14) 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
15) Write a program in C#.Net to create a function to check whether a number is prime or not.
using System;
public class funcexer9
{
public static bool chkprime(int num)
{
for (int i=2; i < num; i++)
if (num %i == 0)
return false;
return true;
}
public static void Main()
{
Console.Write("\n\nFunction : To check a number is prime or not :\n");
Console.Write("-------------------------------------------\n");
Console.Write("Input a number : ");
int n= Convert.ToInt32(Console.ReadLine());
if (chkprime(n))
Console.WriteLine(n+" is a prime number");
else
Console.WriteLine(n+" is not a prime number");
}
}
16) Write a VB.NET program to create Author table (aid, aname, book_ name). Insert the
records (Max 5). Delete a record of author who has written “VB.NET book” and display
remaining records on the data grid view. (Use MS Access to create db.)
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDbConnection("Provider = MICROSOFT.JET.OLEDB.4.0;data
Source=D:\sym\VB.NET\CRYST\crystdel\Author.mdb")
Dim cmd As New OleDbCommand
Dim ad As New OleDbDataAdapter
Dim ds As New DataSet
Dim rd As OleDbDataReader
17) Write a VB.NET program to design following screen, accept the details from the
user. Clicking on Submit button Net Salary should be calculated and displayed into the
Textbox. Display the Messagebox informing the Name and Net Salary of employee.
18) Write a VB.NET program to accept the details Supplier (SupId, SupName, Phone
No, Address) store it into the database and display it.
Imports System.Data.OleDb
Imports System.Data
Public Class Form1
19) 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
20) Write a VB.NET program to create a table student (Roll No, SName, Class,City). Insert
the records (Max: 5). Update city of students to ‘Pune’ whose city is ‘Mumbai’ and
display updated records in GridView
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDbConnection("Provider = MICROSOFT.JET.OLEDB.4.0;data
Source=D:\sym\VB.NET\Student.mdb")
Dim cmd As New OleDbCommand
Imports System.Data.OleDb
Imports System.Data
Public Class Form1