Documente Academic
Documente Profesional
Documente Cultură
USAGE OF STRUCTURES
ALGORITHM:
1
Compute a-b
Print the
sub(a,b)
Return
value
Start
FLOWCHART:MULTILEVEL INHERITANCE
Create a structure for
student with required
Start fields. Addi(a,b)
Addi(a,b)
Print the
Display all the details value of z
inside the student class
using the method
Subt(a,b) showdata().
Return
Div(a,b)
Int z;
Stop Z=a-b;
Stop
Print the
value of z
Return
2
PROGRAM:
using System;
public class add
{
public void addi(int a ,int b)
{
int z;
z=a+b;
Console.WriteLine("after doing addition"+z);
}}
public class sub:add
{
public void subt(int a,int b)
{
int z;
z=a-b;
Console.WriteLine("after doing subtration"+z)}}
public class mul:sub
{
public void mult(int a,int b)
{
int z;
z=a*b;
Console.WriteLine("after doing Multiplication"+z) }}
public class div:mul
{
public void divi(int a,int b)
{
int z;
z=a/b;
Console.WriteLine("after doing divison"+z);
}
}
3
OUTPUT:
After Addition : 10
After Subtraction: 0
After Multiplication : 25
After Division : 1
4
RESULT: Thus the program was written & output was verified.
5
EXP NO.: 4
INTERFACES
1. Create 4 interfaces.
Create object of
2. Inherit
classthem
trail1toand
a class & define the functions declared in those interfaces.
call the function
3. In the main program, create an object of derived class and call all the
usins defined.
object Compute a+b
functions
Add(a,b)
Print the
value
Sub(a,b)
Return
Stop
6
FLOWCHART: INTERFACE
Start
Stop
7
PROGRAM:
using System;
interface i1
{
void add();
}
interface i2
{
void sub();
}
interface i3
{
void mul();
}
interface i4
{
void div();
}
class xyz:i1,i2,i3,i4
{
public int a,b;
public void get()
{
Console.WriteLine("Enter The A value");
a=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter The B value");
b=Convert.ToInt32(Console.ReadLine());
}
public void add()
{
int z;
z=a+b;
Console.WriteLine("after doing addition"+z);
}
8
z=a*b;
Console.WriteLine("after doing multiplication"+z);
}
class multiple
{
public static void Main(String []args)
{
xyz obj=new xyz();
obj.get();
i1 obj1=(i1) obj;
obj1.add();
i2 obj2=(i2) obj;
obj2.sub();
i3 obj3=(i3) obj;
obj3.mul();
i4 obj4=(i4) obj;
obj4.div();
}
}
9
OUTPUT:
After Addition : 10
After Subtraction: 0
After Multiplication : 25
After Division : 1
10
RESULT: Thus the program was written & output was verified.
11
EXP NO.: 5
DELEGATES
ALGORITHM:
1. Declare a delegate.
2. Create a new class and define 2-3 methods with same signature as of the
delegate.
3. Write the main program & create an object of delegate.
4. Pass the function names as arguments (parameter) to the delegate.
12
FLOWCHART: DELEGATES.
Start
Print1() Print2()
Stop
13
PROGRAM:
using system;
public delegate void dell();
public class b1
{
public void print1()
{
Console.WriteLine (“This is Function 1\n”);
}
public void print2()
{
Console.WriteLine (“This is Function 2\n”);
}
}
class main
{
public static void Main()
{
b1 a = new b1();
dell x = new dell(a.print1);
x+ = new dell(a.print2);
x();
Console.ReadLine();
}
}
14
OUTPUT:
This is Function 1
This is Function 2
15
RESULT: Thus the program was written & output was verified.
16
EXP NO.: 6
MOUSE EVENTS
ALGORITHM:
17
PROGRAM:
using System;
using System.Windows.Forms;
class WinF:Form
{
public WinF()
{
Top=100;
Left=75;
Height=100;
Width=500;
this.MouseUp+=new MouseEventHandler(OnMo);
this.MouseMove+=new MouseEventHandler(OnMM);
}
public void OnMo(object O,MouseEventArgs M)
{
string s=string.Format("CurrentPosition:{0},{1}",M.X,M.Y);
MessageBox.Show(s);
}
public void OnMM(object O,MouseEventArgs M)
{
this.Text=string.Format("CurrentPosition:{0},{1}",M.X,M.Y);
}
public static void Main()
{
Application.Run(new WinF());
}
}
18
OUTPUT:
19
RESULT: Thus the program was written & output was verified.
20
EXP NO.: 7
MENUS
ALGORITHM:
21
PROGRAM:
using System;
using System.Windows.Forms;
class WinFF:Form
{
public WinFF()
{
MainMenu M=new MainMenu();
MenuItem M1=new MenuItem("file");
MenuItem M2=new MenuItem("open");
MenuItem M3=new MenuItem("save");
MenuItem M4=new MenuItem("exit");
MenuItem M5=new MenuItem("Edit");
M1.MenuItems.Add(M2);
M1.MenuItems.Add(M3);
M1.MenuItems.Add(M4);
M.MenuItems.Add(M1);
this.Menu = M;
}
public static void Main()
{
Application.Run(new WinFF());
}
}
22
OUTPUT:
23
RESULT: Thus the program was written & output was verified.
24
EXP NO.: 8
TEXT BOX
ALGORITHM:
25
PROGRAM:
using System;
using System.Windows.Forms;
using System.Drawing;
class teb:Form
{
TextBox T1=new TextBox();
TextBox T2=new TextBox();
TextBox T3=new TextBox();
Button B1=new Button();
Button B2=new Button();
Button B3=new Button();
public teb()
{
T1.Location=new System.Drawing.Point(10,10);
T1.Size=new System.Drawing.Size(150,100);
T1.Multiline=true;
T1.ScrollBars=ScrollBars.Both;
B1.Location=new System.Drawing.Point(180,10);
B1.Text="Reveal";
T2.Location=new System.Drawing.Point(10,120);
T2.Size=new System.Drawing.Size(150,20);
T2.PasswordChar='*';
B2.Location=new System.Drawing.Point(180,120);
B2.Text="Reveal";
T3.Location=new System.Drawing.Point(10,120);
T3.Size=new System.Drawing.Size(50,10);
T3.CharacterCasing=CharacterCasing.Upper;
B3.Location=new System.Drawing.Point(110,34);
B3.Text="Upper";
this.Click+=new EventHandler(Button_B1);
this.Click+=new EventHandler(Button_B2);
this.Click+=new EventHandler(Button_B3);
this.Controls.Add(T1);
this.Controls.Add(T2);
this.Controls.Add(T3);
this.Controls.Add(B1);
this.Controls.Add(B2);
this.Controls.Add(B3);
}
26
public void Button_B1(object O, EventArgs M)
{
MessageBox.Show(T1.Text);
}
27
OUTPUT:
Sample Output
28
RESULT: Thus the program was written & output was verified.
29
EXP NO.: 9
LIST BOX
ALGORITHM:
PROGRAM:
30
using System;
using System.Windows.Forms;
using System.Drawing;
OUTPUT:
31
32
RESULT: Thus the program was written & output was verified.
33
EXP NO.:10
ALGORITHM:
34
Program: -
using System;
using System.Windows.Forms;
public Win()
{
gb.Controls.Add(r2);
this.Controls.Add(cb1);
cb1.Location=new System.Drawing.Point(300,200);
this.Controls.Add(cb2);
cb2.Location=new System.Drawing.Point(200,300);
gb.Controls.Add(r1);
gb.Controls.Add(r2);
this.Controls.Add(gb);
gb.Enter+=new EventHandler(onEnter);
}
35
OUTPUT
36
Result: -The program has been created and run successful
37