You are on page 1of 150

Ex No: 01 06-06-2012

SUM OF TWO NUMBERS

AIM:

To create a windows application for find the sum of two numbers.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Sum_of_2_numbers { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int a, b, ans; a = int.Parse(textBox1.Text); b = int.Parse(textBox2.Text); ans = a + b;

textBox3.Text = ans.ToString();

} }

OUTPUT:

Result is:

RESULT:

Finally a windows application is created for find the sum of two Numbers. Ex No: 02 08-06-2012 CONCATINATION OF TWO STRINGS

AIM:

To create a windows application for find the concatenation of two strings.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic; using System.ComponentModel;

using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Sum_of_2_numbers { public partial class CONCATINATION_OF_TWO_STRINGS : Form { public CONCATINATION_OF_TWO_STRINGS() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { String s1, s2, s3; s1 = textBox1.Text; s2 = textBox2.Text; s3 = s1 + s2; textBox3.Text = s3; } } }

OUTPUT:

After entering strings,

After pressing Concatenation button

RESULT:

Finally a windows application is created for find the concatenation of two strings. Ex No: 03 08-06-2012 TEXT BOX FORECOLOR CHANGING USING BUTTONS

AIM:

To create a windows application for changing the text box fore color using ratio buttons.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Textbox_Forecolor { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked == true) { textBox1.Text = "RED IS SELECTED"; textBox1.ForeColor = Color.Red; } if (radioButton2.Checked == true) { textBox1.Text = "BLUE IS SELECTED"; textBox1.ForeColor = Color.Blue; } if (radioButton3.Checked == true) { textBox1.Text = "GREEN IS SELECTED"; textBox1.ForeColor = Color.Green; } }

private void button2_Click(object sender, EventArgs e) { radioButton1.Checked = false; radioButton2.Checked = false; radioButton3.Checked = false; }

} }

OUPUT:

After selecting

After clicking

RESULT:

Finally a windows application is created for changing the text box fore color using Ratio Buttons.

Ex No: 04 13-06-2012

GREATEST OF TWO NUMBERS

AIM:

To create a windows application for find the greatest number among two numbers.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Greatest_of_3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { int a, b; a = int.Parse(textBox1.Text); b = int.Parse(textBox2.Text); if (a > b) MessageBox.Show("Greatest Number is A");

else MessageBox.Show("Greatest Number is B"); } } }

OUTPUT:

After giving 2 numbers

Result is

RESULT:

Finally a windows application is created for find the greatest number among two numbers. Ex No: 05 15-06-2012 CALCULATOR

AIM:

To create a windows application for calculator.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic;

using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Calculator { public partial class Form1 : Form { public Form1() { InitializeComponent(); Application.Run(new Form2()); } Double total1; Double total2; bool plusButtonClicked = false; bool minusButtonClicked = false; bool multiplyButtonClicked = false; bool divisionButtonClicked = false;

private void button1_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button1.Text; }

private void button2_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button2.Text;

private void button3_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button3.Text; }

private void button4_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button4.Text; }

private void button5_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button5.Text; }

private void button6_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button6.Text; }

private void button7_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button7.Text; }

private void button8_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button8.Text;

private void button9_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button9.Text; }

private void button10_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button10.Text; }

private void button13_Click(object sender, EventArgs e) { total1 = total1 + Double.Parse(textBox1.Text); textBox1.Clear(); plusButtonClicked = true; minusButtonClicked = false; multiplyButtonClicked = false; divisionButtonClicked = false; }

private void button14_Click(object sender, EventArgs e) { total1 = total1 + Double.Parse(textBox1.Text); textBox1.Clear(); plusButtonClicked = false; minusButtonClicked = true; multiplyButtonClicked = false; divisionButtonClicked = false;

private void button15_Click(object sender, EventArgs e) { total1 = total1 + Double.Parse(textBox1.Text); textBox1.Clear(); plusButtonClicked = false; minusButtonClicked = false; multiplyButtonClicked = true; divisionButtonClicked = false; }

private void button16_Click(object sender, EventArgs e) { total1 = total1 + Double.Parse(textBox1.Text); textBox1.Clear(); plusButtonClicked = false; minusButtonClicked = false; multiplyButtonClicked = false; divisionButtonClicked = true; }

private void button11_Click(object sender, EventArgs e) { if (plusButtonClicked == true) total2 = total1 + Double.Parse(textBox1.Text); else if (minusButtonClicked == true) total2 = total1 - Double.Parse(textBox1.Text); else if (multiplyButtonClicked == true) total2 = total1 * Double.Parse(textBox1.Text);

else if (divisionButtonClicked == true) total2 = total1 / Double.Parse(textBox1.Text); textBox1.Text = total2.ToString(); total1 = 0; }

private void button12_Click(object sender, EventArgs e) { textBox1.Clear(); }

private void button17_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button17.Text; } } }

OUTPUT:

First Number input:

Second number input:

RESULT:

RESULT:

Finally a windows application is created for calculator. Ex No: 06 15-06-2012 ELECTRICITY BILL GENERATION

AIM:

To create a windows application for Generate electricity bill.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Calculator

{ public partial class Form2 : Form { public Form2() { InitializeComponent(); Application.Run(new Form3()); }

private void button1_Click(object sender, EventArgs e) { int unit; int u1=99, u2=0, u3=0, u4=0; unit = int.Parse(textBox3.Text); if (unit < 99) u1 = unit; else if ((unit >= 100) && (unit < 199)) u2=unit-u1; else if ((unit >= 200) && (unit < 499)) { u2 = 100; u3 = unit - u1 - u2; } else if (unit >= 500) { u2 = 100; u3 = 300; u4 = unit - u1 - u2 - u3; } unit = (u1 * 2) + (u2 * 3) + (u3 * 4) + (u4 * 5);

textBox4.Text = unit.ToString(); }

private void button2_Click(object sender, EventArgs e) { textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); } } }

OUTPUT:

RESULT:

Finally a windows application is created for Generate Electricity Bill. Ex No: 07 22-06-2012 STUDENT MARKLIST

AIM:

To create a windows application for Display the student mark list.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Calculator { public partial class Form3 : Form { public Form3() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { String name,result; int reg,m1,m2,m3,m4,m5; int total; Double avg; name=textBox1.Text;

reg=int.Parse(textBox2.Text); m1 = int.Parse(textBox3.Text); m2 = int.Parse(textBox4.Text); m3 = int.Parse(textBox5.Text); m4 = int.Parse(textBox6.Text); m5 = int.Parse(textBox7.Text); total = m1 + m2 + m3 + m4 + m5; avg = (total / 5);

label8.Visible = true; label9.Visible = true; label10.Visible = true; label11.Visible = true; textBox8.Visible = true; textBox9.Visible = true; textBox10.Visible = true; textBox11.Visible = true;

if ((m1 >= 40) && (m2 >= 40) && (m3 >= 40) && (m4 >= 40) && (m5 >= 50)) result = "PASS"; else result = "FAIL"; if (result == "PASS") { if (avg >= 90) textBox11.Text = "S"; else if (avg >= 80) textBox11.Text = "A"; else if (avg >= 70) textBox11.Text = "B";

else if (avg >= 60) textBox11.Text = "C"; else if (avg >= 50) textBox11.Text = "D"; }

textBox8.Text=total.ToString(); textBox9.Text=avg.ToString(); textBox10.Text=result; }

private void button2_Click(object sender, EventArgs e) { textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); textBox6.Clear(); textBox7.Clear(); label8.Visible = false; label9.Visible = false; label10.Visible = false; label11.Visible = false; textBox8.Visible = false; textBox9.Visible = false; textBox10.Visible = false; textBox11.Visible = false; } }

OUTPUT:

RESULT:

Finally a windows application is created for Display the Student Mark List. Ex No : 08 SWAP OF TWO NUMBERS

27-06-2012

AIM : To write a console application for swap 2 numbers by value and reference.

ALGORITHM:

Step 1 : START Step 2 : Declare and assign the values a and b Step 3 : Pass the Values to Swap Function and print the values Step 4 : Print the values in Main() Step 5 : Pass the Reference to Swap Function and print the values Step 6 : Print the values in Main() Step 7 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Swap_value { class Program { static void Main(string[] args) { int a = 100, b = 200; Program p = new Program(); Console.WriteLine("In main....");

Console.WriteLine("\na={0} , b={1} ", a, b); p.swap(a, b); Console.WriteLine("\nIn main...."); Console.WriteLine("\na={0} , b={1} ", a, b); p.swap(ref a, ref b); Console.WriteLine("In main...."); Console.WriteLine("\na={0} , b={1} ", a, b); Console.ReadKey(); } public void swap(int x, int y) { int t = 0; t = x; x = y; y = t; Console.Write("\nBy Value...."); Console.WriteLine("\n a={0}, b={1} ", x, y); } public void swap(ref int x, ref int y) { int t = 0; t = x; x = y; y = t; Console.Write("\nBy Reference...."); Console.WriteLine("\n a={0}, b={1} ", x, y); } } }

OUTPUT:

RESULT:

Finally a console application is created for Swap Two Numbers by value and reference. Ex No: 09 27-06-2012 IMPLEMENTATION OF ARRAY

AIM: To write a console application for implement the array concepts.

ALGORITHM:

Step 1 : START Step 2 : Declare an array Step 3 : By using for loop get the values for Array Step 4 : Print the Array Elements Step 5 : Using SetValue to assign first value as 3 Step 6 : Print the Array length using Length function Step 8 : Print the Reversed array using Reverse Function Step 9 : Print the Sorted array using Sort Function Step 10:STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Implementation_of_Array { class Program { static void Main(string[] args) { int[] a = new int[5]; int i, t; String s; Console.Write("Enter 5 Elements : \n"); for (i = 0; i < a.Length; i++) { s = Console.ReadLine(); t = int.Parse(s); a.SetValue(t, i); } Console.Write("Array Elements are... \n"); for (i = 0; i < a.Length; i++) Console.WriteLine("{0}", a.GetValue(i)); Console.Write("\nARRAY IMPLEMENTATION"); Console.WriteLine("\n\nUsing SetValue...."); a.SetValue(3, 1); Console.WriteLine("1st Element is : {0} ", a.GetValue(1)); Console.Write("\nLength of Array is :"); Console.WriteLine("{0}", a.Length); Array.Reverse(a); Console.Write("\nReverse Array is...\n"); for (i = 0; i < a.Length; i++) Console.WriteLine("{0}",a.GetValue(i));

Array.Sort(a); Console.Write("\nSorted Array is...\n"); for (i = 0; i < a.Length; i++) Console.WriteLine("{0}", a.GetValue(i)); Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for implement the array concepts. Ex No: 10 27-06-2012 MATRIX MULTIPLICATION

AIM: To write a console application to perform matrix multiplication.

ALGORITHM:

Step 1 : START Step 2 : Declare three arrays named as a,b and c Step 3 : Using for loop to get values for the matrices a and b Step 4 : Using for loop to calculate the value for c Step 5 : Display the resultant matrix Step 6 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Matrix_Multipplication { class Program { static void Main(string[] args) { int[,] a = new int[10, 10]; int[,] b = new int[10, 10]; int[,] c = new int[10, 10]; String s; int i, j, n, t; Console.Write("Enter the Size of the Array : "); s = Console.ReadLine(); n = int.Parse(s); Console.Write("\nEnter First Array Elements : "); for(i=0;i<n;i++) for(j=0;j<n;j++) { Console.WriteLine("\nEnter a[{0},{1}] Element : ",i,j); s=Console.ReadLine(); t = int.Parse(s); a.SetValue(t, i, j); } Console.Write("\nEnter Second Array Elements : "); for (i = 0; i < n; i++) for (j = 0; j < n; j++) { Console.WriteLine("\nEnter b[{0},{1}] Element : ", i, j); s = Console.ReadLine(); t = int.Parse(s);

b.SetValue(t, i, j); c[i, j] = a[i, j] * b[i, j]; } Console.Write("\nMatrix Multiplication is....."); for (i = 0; i < n; i++) { Console.Write("\n"); for (j = 0; j < n; j++) Console.Write("{0} ", c[i, j]); Console.WriteLine("\n"); } Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for perform matrix multiplication. Ex No: 11 29-06-2012 STUDENT MARKLIST USING STRUCTURES

AIM: To write a console application for display the student mark list using structures.

ALGORITHM:

Step 1 : START Step 2 : Create a Structure called Student with suitable variables and methods Step 3 : Create objects for structure in main function Step 4 : Call the methods for Input details, Calculate Average & Grade Step 5 : Display the the Student Details Step 6 : STOP

CODING:

using System;

using System.Collections.Generic; using System.Text;

namespace Student_Marklist { class Program { struct Student { String Name, Grade, t; int Roll_Number, m1, m2, m3, m4, m5, Total; float Average;

public void Input() { Console.Write("Enter Your Name : "); Name = Console.ReadLine(); Console.Write("Enter Your Roll Number : "); t = Console.ReadLine(); Roll_Number = int.Parse(t);

Console.Write("Enter Your Mark 1 : "); t = Console.ReadLine(); m1 = int.Parse(t);

Console.Write("Enter Your Mark 2 : "); t = Console.ReadLine(); m2 = int.Parse(t);

Console.Write("Enter Your Mark 3 : ");

t = Console.ReadLine(); m3 = int.Parse(t);

Console.Write("Enter Your Mark 4 : "); t = Console.ReadLine(); m4 = int.Parse(t);

Console.Write("Enter Your Mark 5 : "); t = Console.ReadLine(); m5 = int.Parse(t); }

public void Calculate() { Total = m1 + m2 + m3 + m4 + m5; Average = (Total / 5); if (Average >= 90) Grade = "S"; else if (Average >= 80) Grade = "A"; else if (Average >= 70) Grade = "B"; else if (Average >= 60) Grade = "C"; else if (Average >= 50) Grade = "D"; }

public void Display() {

Console.Write("\n\n\t STUDENT MARKLIST"); Console.Write("\n\n Name : {0}", Name);

Console.Write("\n Total : {0}", Total); Console.Write("\n Average : {0}", Average); Console.Write("\n Grade } }; : {0}", Grade);

static void Main(string[] args) { Student s1 = new Student(); s1.Input(); s1.Calculate(); s1.Display(); Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for display the student mark list using structures. Ex No: 12 04-07-2012 SEARCHING AN ELEMENT IN THE ARRAY

AIM: To write a console application for searching an element in the array.

ALGORITHM:

Step 1 : START Step 2 : Declare a array called a and variables for searching Step 3 : Get array size and array elements

Step 4 : Get the Searching element for searching Step 5 : Using for and if loops for searching Step 6 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Search_an_Element { class Program { static void Main(string[] args) { int[] a = new int[100]; String str; int i, n, t,s; Console.Write("Enter the Size of the Array : "); str = Console.ReadLine(); n = int.Parse(str); Console.Write("\nEnter Array Elements : "); for (i = 0; i < n; i++) { str = Console.ReadLine(); t = int.Parse(str); a.SetValue(t, i); } Console.Write("Enter The Number to be Searched : ");

str = Console.ReadLine(); s = int.Parse(str); for (i = 0; i < n; i++) if (a[i] == s) Console.WriteLine("\nNumber Is FOUND at {0}th Position", i); Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for searching an element in the array. Ex No: 13 04-07-2012 GREATEST OF THREE NUMBERS

AIM: To write a console application for find the greatest number among three numbers.

ALGORITHM:

Step 1 : START Step 2 : Declare Three variables Step 3 : Get Three values for three variables Step 4 : Using if loops for find greatest number Step 5 : Display the greatest number Step 6 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Greatest_of_3_Numbers { class Program { static void Main(string[] args) { int a, b, c; String str; Console.Write("\nEnter Value for a : "); str = Console.ReadLine(); a = int.Parse(str);

Console.Write("\nEnter Value for b : "); str = Console.ReadLine(); b = int.Parse(str);

Console.Write("\nEnter Value for c : "); str = Console.ReadLine(); c = int.Parse(str);

if ((a > b) && (a > c)) Console.Write("\nGreatest Number is A = {0}", a); else if ((b > a) && (b > c)) Console.Write("\nGreatest Number is B = {0}", b); else if ((c > a) && (c > b)) Console.Write("\nGreatest Number is C = {0}", c); else Console.Write("\nTwo Numbers are Equal"); Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for greatest number among three numbers. Ex No: 14 04-07-2012 PASCAL TRIANGLE

AIM: To write a console application for print the Pascal triangle.

ALGORITHM:

Step 1 : START Step 2 : Declare variables Step 3 : Get the value for total rows Step 4 : Using loops for print pascal triangle Step 5 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Pascal_triangle { class Program { static void Main(string[] args)

{ Program P =new Program(); int i, n, c; int t1,t2,t3; String s; Console.Write("Enter Total rows : "); s = Console.ReadLine(); n = int.Parse(s); for (i = 0; i < n; i++) { for (c = 0; c <= n-i-2; c++) Console.Write(" "); for (c = 0; c <= i; c++) { t1 = P.factorial(i); t2 = P.factorial(c); t3 = P.factorial(i - c); Console.Write(" {0} ", t1 / (t2 * t3)); } Console.Write("\n"); } Console.ReadKey(); } public int factorial(int a) { int i, result=1; for (i = 1; i <= a; i++) result = result * i; return result; }

} } OUTPUT:

RESULT:

Finally a console application is created for print the Pascal triangle. Ex No: 15 06-07-2012 EMPLOYEE PAY COLLECTION

AIM: To write a console application for finding the total salary (NET) for N employees.

ALGORITHM:

Step 1 : START Step 2 : Create a Structure called employee with suitable variables and methods Step 3 : Create objects for structure in main function Step 4 : Get the Number of employees from user Step 5 : Get the Employee Details and Calculate Net salary using for loop Step 6 : Display the Employees Paybill Using for loop Step 7 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Employee_Pay_Collection { class Program { struct employee { String Name, s, position; int id, Basic, Net, allow, detections, pf, hra, loan, ta;

public void input() { Console.Write("\nEnter Your Name : "); Name = Console.ReadLine(); Console.Write("Enter Your Employee ID : "); s = Console.ReadLine(); id = int.Parse(s); Console.Write("Enter Your Basic Pay : "); s = Console.ReadLine(); Basic = int.Parse(s); Console.Write("Enter Your PF : "); s = Console.ReadLine(); pf = int.Parse(s); Console.Write("Enter Your Loan : ");

s = Console.ReadLine(); loan = int.Parse(s); Console.Write("Enter Your HRA : "); s = Console.ReadLine(); hra = int.Parse(s); Console.Write("Enter Your TA : "); s = Console.ReadLine(); ta = int.Parse(s); }

public void calculate() { allow=Basic+hra+ta; detections=pf+loan; Net=allow-detections; if (Net >= 60000) position = "MANAGER"; else if (Net >= 50000) position = "SUPER VISER"; else position = "EMPLOYEE"; }

public void display() { Console.Write("\n{0}\t{1}\t{2}\t{3}\t\"{4}\"", Name,id,Basic,Net,position); } };

static void Main(string[] args)

{ int i,n; string s; employee []e = new employee[10]; Console.Write("Enter Total Employees : "); s=Console.ReadLine(); n=int.Parse(s); for (i = 0; i < n; i++) { e[i].input(); e[i].calculate(); } Console.Write("\n\tPAYBILL GENERATION"); Console.Write("\n\n NAME \tID \tBASIC \tNET \tDESGINATION"); for (i = 0; i < n; i++) e[i].display(); Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for the total salary (NET) for N employees. Ex No: 16 11-07-2012 MULTIPLICATION TABLE

AIM: To write a console application for print the multiplication table for three, four and seven.

ALGORITHM:

Step 1 : START Step 2 : Declare 3 arrays called three, four, seven and initialize the arrays

Step 3 : Using foreach loop for display the 3rd ,4th and 7th Multiplication Table Step 4 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Multiplication_table { class Program { static void Main(string[] args) { int[] three = new int[] { 3, 6, 9, 12, 15, 18, 21, 24, 27, 30 }; int[] four = new int[] { 4, 6, 12, 16, 20, 24, 28, 32, 36, 40 }; int[] seven = new int[] { 7, 14, 21, 28, 35, 42, 49, 56, 63, 70 }; int i = 0; Console.Write("Multiple Tables....."); Console.Write("\n\nTHREE\n"); foreach(Object k in three) { Console.Write("\n{0} * 3 = {1}",i+1,k); i++; } i = 0; Console.Write("\n\nFOUR\n"); foreach (Object k in four) {

Console.Write("\n{0} * 4 = {1}", i + 1, k); i++; } i = 0; Console.Write("\n\nSEVEN\n"); foreach (Object k in seven) { Console.Write("\n{0} * 7 = {1}", i + 1, k); i++; } Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for print the multiplication table for three, four and seven. Ex No: 17 11-07-2012 PATTERN OF WORD MATCHING

AIM: To write a console application for calculate the total and and from in the given sentence.

ALGORITHM:

Step 1 : START Step 2 : Declare 2 arrays called and & from and also initialize the arrays Step 3 : Get the String for calculate the words Step 4 : Using foreach loop for count the and & from in the entered string Step 5 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Word_Matching { class Program { static void Main(string[] args) { String s; String[] and ={"and","And","AND"}; String[] from = {"from","From","FROM"}; int Count1=0,Count2=0; Console.Write("Enter a String : "); s = Console.ReadLine(); String[] given = s.Split(); foreach (String i in given) { foreach (String j in and) if (i == j) Count1+=1; foreach (String j in from) if (i == j) Count2+=1; } Console.WriteLine("\nAnd = {0}\nFrom = {1}", Count1, Count2); Console.ReadKey();

} } }

OUTPUT:

RESULT:

Finally a console application is created for calculate the total and and from in the given sentence. Ex No: 18 11-07-2012 SALES IN STATIONARY SHOP

AIM: To write a console application for calculate the bill amount in a stationary shop.

ALGORITHM:

Step 1 : START Step 2 : Create a class called stationary with suitable variables, methods and Constructor Step 3 : Create Object for stationary with connstructor Step 4 : Call input for get inputs Step 5 : Call Calculate for calculating total amount for all items Step 6 : Display the total bill amount Step 7 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Stationary_Shop { class Program { static void Main(string[] args) { stationary s=new stationary(10,5,10,50,0); s.Input(); s.Calculate(); s.Display(); Console.ReadKey(); } }

class stationary { String[] items=new String[4]{"Pen","Pencil","Paper","Note"}; int[] prize=new int[4]; int[] Qty=new int[4]; int[] total=new int[4]; int Total=0;

public stationary(int a,int b,int c,int d,int e) { prize[0]=a; prize[1]=b; prize[2]=c; prize[3]=d; for (int i = 0; i < 4;i++ ) Qty[i] = e; } public void Input() { string s; Console.Write("\nEnter the Following Quantity....\n ");

Console.Write("\nPen,Pencil,Paper,Note : "); for(int i=0;i<4;i++) { s=Console.ReadLine(); Qty[i]=int.Parse(s); } }

public void Calculate() { for(int i=0;i<4;i++) { total[i]=Qty[i]*prize[i]; Total+=total[i]; } }

public void Display() { Console.Write("\n\t\t\"\"Bill\"\"\n"); Console.Write("\nItem Name\tPrize\tQuantity\tTotal\n"); for(int i=0;i<4;i++) Console.Write("\n{0}\t\t{1}\t{2}\t\t{3}",items[i],prize[i],Qty[i],total[i]); Console.WriteLine("\n\n Total Bill Amount is {0} Rupees ", Total); } }

OUTPUT:

RESULT:

Finally a console application is created for calculate the bill amount in a stationary shop.Ex No: 01 SUM OF TWO NUMBERS 06-06-2012

AIM:

To create a windows application for find the sum of two numbers.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Sum_of_2_numbers { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int a, b, ans; a = int.Parse(textBox1.Text); b = int.Parse(textBox2.Text); ans = a + b; textBox3.Text = ans.ToString();

} }

OUTPUT:

Result is:

RESULT:

Finally a windows application is created for find the sum of two Numbers. Ex No: 02 08-06-2012 CONCATINATION OF TWO STRINGS

AIM:

To create a windows application for find the concatenation of two strings.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Sum_of_2_numbers {

public partial class CONCATINATION_OF_TWO_STRINGS : Form { public CONCATINATION_OF_TWO_STRINGS() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { String s1, s2, s3; s1 = textBox1.Text; s2 = textBox2.Text; s3 = s1 + s2; textBox3.Text = s3; } } }

OUTPUT:

After entering strings,

After pressing Concatenation button

RESULT:

Finally a windows application is created for find the concatenation of two strings. Ex No: 03 08-06-2012 TEXT BOX FORECOLOR CHANGING USING BUTTONS

AIM:

To create a windows application for changing the text box fore color using ratio buttons.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Textbox_Forecolor { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked == true) { textBox1.Text = "RED IS SELECTED"; textBox1.ForeColor = Color.Red;

} if (radioButton2.Checked == true) { textBox1.Text = "BLUE IS SELECTED"; textBox1.ForeColor = Color.Blue; } if (radioButton3.Checked == true) { textBox1.Text = "GREEN IS SELECTED"; textBox1.ForeColor = Color.Green; } }

private void button2_Click(object sender, EventArgs e) { radioButton1.Checked = false; radioButton2.Checked = false; radioButton3.Checked = false; }

} }

OUPUT:

After selecting

After clicking

RESULT:

Finally a windows application is created for changing the text box fore color using Ratio Buttons. Ex No: 04 13-06-2012 GREATEST OF TWO NUMBERS

AIM:

To create a windows application for find the greatest number among two numbers.

FORM DESIGN:

CODING:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Greatest_of_3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { int a, b; a = int.Parse(textBox1.Text); b = int.Parse(textBox2.Text); if (a > b) MessageBox.Show("Greatest Number is A"); else MessageBox.Show("Greatest Number is B"); } } }

OUTPUT:

After giving 2 numbers

Result is

RESULT:

Finally a windows application is created for find the greatest number among two numbers. Ex No: 05 15-06-2012 CALCULATOR

AIM:

To create a windows application for calculator.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Calculator

{ public partial class Form1 : Form { public Form1() { InitializeComponent(); Application.Run(new Form2()); } Double total1; Double total2; bool plusButtonClicked = false; bool minusButtonClicked = false; bool multiplyButtonClicked = false; bool divisionButtonClicked = false;

private void button1_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button1.Text; }

private void button2_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button2.Text; }

private void button3_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button3.Text; }

private void button4_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button4.Text; }

private void button5_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button5.Text; }

private void button6_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button6.Text; }

private void button7_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button7.Text; }

private void button8_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button8.Text; }

private void button9_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button9.Text; }

private void button10_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button10.Text; }

private void button13_Click(object sender, EventArgs e) { total1 = total1 + Double.Parse(textBox1.Text); textBox1.Clear(); plusButtonClicked = true; minusButtonClicked = false; multiplyButtonClicked = false; divisionButtonClicked = false; }

private void button14_Click(object sender, EventArgs e) { total1 = total1 + Double.Parse(textBox1.Text); textBox1.Clear(); plusButtonClicked = false; minusButtonClicked = true; multiplyButtonClicked = false; divisionButtonClicked = false; }

private void button15_Click(object sender, EventArgs e) { total1 = total1 + Double.Parse(textBox1.Text); textBox1.Clear(); plusButtonClicked = false;

minusButtonClicked = false; multiplyButtonClicked = true; divisionButtonClicked = false; }

private void button16_Click(object sender, EventArgs e) { total1 = total1 + Double.Parse(textBox1.Text); textBox1.Clear(); plusButtonClicked = false; minusButtonClicked = false; multiplyButtonClicked = false; divisionButtonClicked = true; }

private void button11_Click(object sender, EventArgs e) { if (plusButtonClicked == true) total2 = total1 + Double.Parse(textBox1.Text); else if (minusButtonClicked == true) total2 = total1 - Double.Parse(textBox1.Text); else if (multiplyButtonClicked == true) total2 = total1 * Double.Parse(textBox1.Text); else if (divisionButtonClicked == true) total2 = total1 / Double.Parse(textBox1.Text); textBox1.Text = total2.ToString(); total1 = 0; }

private void button12_Click(object sender, EventArgs e)

{ textBox1.Clear(); }

private void button17_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + button17.Text; } } }

OUTPUT:

First Number input:

Second number input:

RESULT:

RESULT:

Finally a windows application is created for calculator. Ex No: 06 15-06-2012 ELECTRICITY BILL GENERATION

AIM:

To create a windows application for Generate electricity bill.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Calculator { public partial class Form2 : Form { public Form2() { InitializeComponent(); Application.Run(new Form3());

private void button1_Click(object sender, EventArgs e) { int unit; int u1=99, u2=0, u3=0, u4=0; unit = int.Parse(textBox3.Text); if (unit < 99) u1 = unit; else if ((unit >= 100) && (unit < 199)) u2=unit-u1; else if ((unit >= 200) && (unit < 499)) { u2 = 100; u3 = unit - u1 - u2; } else if (unit >= 500) { u2 = 100; u3 = 300; u4 = unit - u1 - u2 - u3; } unit = (u1 * 2) + (u2 * 3) + (u3 * 4) + (u4 * 5); textBox4.Text = unit.ToString(); }

private void button2_Click(object sender, EventArgs e) { textBox1.Clear(); textBox2.Clear();

textBox3.Clear(); textBox4.Clear(); } } }

OUTPUT:

RESULT:

Finally a windows application is created for Generate Electricity Bill. Ex No: 07 22-06-2012 STUDENT MARKLIST

AIM:

To create a windows application for Display the student mark list.

FORM DESIGN:

CODING:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace Calculator { public partial class Form3 : Form { public Form3() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { String name,result; int reg,m1,m2,m3,m4,m5; int total; Double avg; name=textBox1.Text; reg=int.Parse(textBox2.Text); m1 = int.Parse(textBox3.Text); m2 = int.Parse(textBox4.Text); m3 = int.Parse(textBox5.Text); m4 = int.Parse(textBox6.Text); m5 = int.Parse(textBox7.Text); total = m1 + m2 + m3 + m4 + m5;

avg = (total / 5);

label8.Visible = true; label9.Visible = true; label10.Visible = true; label11.Visible = true; textBox8.Visible = true; textBox9.Visible = true; textBox10.Visible = true; textBox11.Visible = true;

if ((m1 >= 40) && (m2 >= 40) && (m3 >= 40) && (m4 >= 40) && (m5 >= 50)) result = "PASS"; else result = "FAIL"; if (result == "PASS") { if (avg >= 90) textBox11.Text = "S"; else if (avg >= 80) textBox11.Text = "A"; else if (avg >= 70) textBox11.Text = "B"; else if (avg >= 60) textBox11.Text = "C"; else if (avg >= 50) textBox11.Text = "D"; }

textBox8.Text=total.ToString();

textBox9.Text=avg.ToString(); textBox10.Text=result; }

private void button2_Click(object sender, EventArgs e) { textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); textBox6.Clear(); textBox7.Clear(); label8.Visible = false; label9.Visible = false; label10.Visible = false; label11.Visible = false; textBox8.Visible = false; textBox9.Visible = false; textBox10.Visible = false; textBox11.Visible = false; } } }

OUTPUT:

RESULT:

Finally a windows application is created for Display the Student Mark List. Ex No : 08 27-06-2012 SWAP OF TWO NUMBERS

AIM : To write a console application for swap 2 numbers by value and reference.

ALGORITHM:

Step 1 : START Step 2 : Declare and assign the values a and b Step 3 : Pass the Values to Swap Function and print the values Step 4 : Print the values in Main() Step 5 : Pass the Reference to Swap Function and print the values Step 6 : Print the values in Main() Step 7 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Swap_value { class Program { static void Main(string[] args) { int a = 100, b = 200; Program p = new Program(); Console.WriteLine("In main...."); Console.WriteLine("\na={0} , b={1} ", a, b); p.swap(a, b); Console.WriteLine("\nIn main...."); Console.WriteLine("\na={0} , b={1} ", a, b); p.swap(ref a, ref b); Console.WriteLine("In main...."); Console.WriteLine("\na={0} , b={1} ", a, b);

Console.ReadKey(); } public void swap(int x, int y) { int t = 0; t = x; x = y; y = t; Console.Write("\nBy Value...."); Console.WriteLine("\n a={0}, b={1} ", x, y); } public void swap(ref int x, ref int y) { int t = 0; t = x; x = y; y = t; Console.Write("\nBy Reference...."); Console.WriteLine("\n a={0}, b={1} ", x, y); } } }

OUTPUT:

RESULT:

Finally a console application is created for Swap Two Numbers by value and reference.

Ex No: 09 27-06-2012

IMPLEMENTATION OF ARRAY

AIM: To write a console application for implement the array concepts.

ALGORITHM:

Step 1 : START Step 2 : Declare an array Step 3 : By using for loop get the values for Array Step 4 : Print the Array Elements Step 5 : Using SetValue to assign first value as 3 Step 6 : Print the Array length using Length function Step 8 : Print the Reversed array using Reverse Function Step 9 : Print the Sorted array using Sort Function Step 10:STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Implementation_of_Array { class Program { static void Main(string[] args) {

int[] a = new int[5]; int i, t; String s; Console.Write("Enter 5 Elements : \n"); for (i = 0; i < a.Length; i++) { s = Console.ReadLine(); t = int.Parse(s); a.SetValue(t, i); } Console.Write("Array Elements are... \n"); for (i = 0; i < a.Length; i++) Console.WriteLine("{0}", a.GetValue(i)); Console.Write("\nARRAY IMPLEMENTATION"); Console.WriteLine("\n\nUsing SetValue...."); a.SetValue(3, 1); Console.WriteLine("1st Element is : {0} ", a.GetValue(1)); Console.Write("\nLength of Array is :"); Console.WriteLine("{0}", a.Length); Array.Reverse(a); Console.Write("\nReverse Array is...\n"); for (i = 0; i < a.Length; i++) Console.WriteLine("{0}",a.GetValue(i)); Array.Sort(a); Console.Write("\nSorted Array is...\n"); for (i = 0; i < a.Length; i++) Console.WriteLine("{0}", a.GetValue(i)); Console.ReadKey(); } }

OUTPUT:

RESULT:

Finally a console application is created for implement the array concepts. Ex No: 10 27-06-2012 MATRIX MULTIPLICATION

AIM: To write a console application to perform matrix multiplication.

ALGORITHM:

Step 1 : START Step 2 : Declare three arrays named as a,b and c Step 3 : Using for loop to get values for the matrices a and b Step 4 : Using for loop to calculate the value for c Step 5 : Display the resultant matrix Step 6 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Matrix_Multipplication { class Program { static void Main(string[] args) { int[,] a = new int[10, 10];

int[,] b = new int[10, 10]; int[,] c = new int[10, 10]; String s; int i, j, n, t; Console.Write("Enter the Size of the Array : "); s = Console.ReadLine(); n = int.Parse(s); Console.Write("\nEnter First Array Elements : "); for(i=0;i<n;i++) for(j=0;j<n;j++) { Console.WriteLine("\nEnter a[{0},{1}] Element : ",i,j); s=Console.ReadLine(); t = int.Parse(s); a.SetValue(t, i, j); } Console.Write("\nEnter Second Array Elements : "); for (i = 0; i < n; i++) for (j = 0; j < n; j++) { Console.WriteLine("\nEnter b[{0},{1}] Element : ", i, j); s = Console.ReadLine(); t = int.Parse(s); b.SetValue(t, i, j); c[i, j] = a[i, j] * b[i, j]; } Console.Write("\nMatrix Multiplication is....."); for (i = 0; i < n; i++) { Console.Write("\n");

for (j = 0; j < n; j++) Console.Write("{0} ", c[i, j]); Console.WriteLine("\n"); } Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for perform matrix multiplication. Ex No: 11 29-06-2012 STUDENT MARKLIST USING STRUCTURES

AIM: To write a console application for display the student mark list using structures.

ALGORITHM:

Step 1 : START Step 2 : Create a Structure called Student with suitable variables and methods Step 3 : Create objects for structure in main function Step 4 : Call the methods for Input details, Calculate Average & Grade Step 5 : Display the the Student Details Step 6 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Student_Marklist { class Program {

struct Student { String Name, Grade, t; int Roll_Number, m1, m2, m3, m4, m5, Total; float Average;

public void Input() { Console.Write("Enter Your Name : "); Name = Console.ReadLine(); Console.Write("Enter Your Roll Number : "); t = Console.ReadLine(); Roll_Number = int.Parse(t);

Console.Write("Enter Your Mark 1 : "); t = Console.ReadLine(); m1 = int.Parse(t);

Console.Write("Enter Your Mark 2 : "); t = Console.ReadLine(); m2 = int.Parse(t);

Console.Write("Enter Your Mark 3 : "); t = Console.ReadLine(); m3 = int.Parse(t);

Console.Write("Enter Your Mark 4 : "); t = Console.ReadLine(); m4 = int.Parse(t);

Console.Write("Enter Your Mark 5 : "); t = Console.ReadLine(); m5 = int.Parse(t); }

public void Calculate() { Total = m1 + m2 + m3 + m4 + m5; Average = (Total / 5); if (Average >= 90) Grade = "S"; else if (Average >= 80) Grade = "A"; else if (Average >= 70) Grade = "B"; else if (Average >= 60) Grade = "C"; else if (Average >= 50) Grade = "D"; }

public void Display() { Console.Write("\n\n\t STUDENT MARKLIST"); Console.Write("\n\n Name : {0}", Name);

Console.Write("\n Total : {0}", Total); Console.Write("\n Average : {0}", Average); Console.Write("\n Grade } }; : {0}", Grade);

static void Main(string[] args) { Student s1 = new Student(); s1.Input(); s1.Calculate(); s1.Display(); Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for display the student mark list using structures. Ex No: 12 04-07-2012 SEARCHING AN ELEMENT IN THE ARRAY

AIM: To write a console application for searching an element in the array.

ALGORITHM:

Step 1 : START Step 2 : Declare a array called a and variables for searching Step 3 : Get array size and array elements Step 4 : Get the Searching element for searching Step 5 : Using for and if loops for searching Step 6 : STOP

CODING:

using System;

using System.Collections.Generic; using System.Text;

namespace Search_an_Element { class Program { static void Main(string[] args) { int[] a = new int[100]; String str; int i, n, t,s; Console.Write("Enter the Size of the Array : "); str = Console.ReadLine(); n = int.Parse(str); Console.Write("\nEnter Array Elements : "); for (i = 0; i < n; i++) { str = Console.ReadLine(); t = int.Parse(str); a.SetValue(t, i); } Console.Write("Enter The Number to be Searched : "); str = Console.ReadLine(); s = int.Parse(str); for (i = 0; i < n; i++) if (a[i] == s) Console.WriteLine("\nNumber Is FOUND at {0}th Position", i); Console.ReadKey(); }

} }

OUTPUT:

RESULT:

Finally a console application is created for searching an element in the array. Ex No: 13 04-07-2012 GREATEST OF THREE NUMBERS

AIM: To write a console application for find the greatest number among three numbers.

ALGORITHM:

Step 1 : START

Step 2 : Declare Three variables Step 3 : Get Three values for three variables Step 4 : Using if loops for find greatest number Step 5 : Display the greatest number Step 6 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Greatest_of_3_Numbers { class Program { static void Main(string[] args) { int a, b, c; String str; Console.Write("\nEnter Value for a : "); str = Console.ReadLine(); a = int.Parse(str);

Console.Write("\nEnter Value for b : "); str = Console.ReadLine(); b = int.Parse(str);

Console.Write("\nEnter Value for c : "); str = Console.ReadLine();

c = int.Parse(str);

if ((a > b) && (a > c)) Console.Write("\nGreatest Number is A = {0}", a); else if ((b > a) && (b > c)) Console.Write("\nGreatest Number is B = {0}", b); else if ((c > a) && (c > b)) Console.Write("\nGreatest Number is C = {0}", c); else Console.Write("\nTwo Numbers are Equal"); Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for greatest number among three numbers. Ex No: 14 04-07-2012 PASCAL TRIANGLE

AIM: To write a console application for print the Pascal triangle.

ALGORITHM:

Step 1 : START Step 2 : Declare variables Step 3 : Get the value for total rows Step 4 : Using loops for print pascal triangle Step 5 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Pascal_triangle { class Program { static void Main(string[] args) { Program P =new Program(); int i, n, c; int t1,t2,t3; String s; Console.Write("Enter Total rows : "); s = Console.ReadLine();

n = int.Parse(s); for (i = 0; i < n; i++) { for (c = 0; c <= n-i-2; c++) Console.Write(" "); for (c = 0; c <= i; c++) { t1 = P.factorial(i); t2 = P.factorial(c); t3 = P.factorial(i - c); Console.Write(" {0} ", t1 / (t2 * t3)); } Console.Write("\n"); } Console.ReadKey(); } public int factorial(int a) { int i, result=1; for (i = 1; i <= a; i++) result = result * i; return result; } } } OUTPUT:

RESULT:

Finally a console application is created for print the Pascal triangle. Ex No: 15 06-07-2012 EMPLOYEE PAY COLLECTION

AIM: To write a console application for finding the total salary (NET) for N employees.

ALGORITHM:

Step 1 : START Step 2 : Create a Structure called employee with suitable variables and methods Step 3 : Create objects for structure in main function Step 4 : Get the Number of employees from user Step 5 : Get the Employee Details and Calculate Net salary using for loop Step 6 : Display the Employees Paybill Using for loop Step 7 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Employee_Pay_Collection { class Program { struct employee { String Name, s, position; int id, Basic, Net, allow, detections, pf, hra, loan, ta;

public void input() { Console.Write("\nEnter Your Name : "); Name = Console.ReadLine(); Console.Write("Enter Your Employee ID : "); s = Console.ReadLine(); id = int.Parse(s); Console.Write("Enter Your Basic Pay : "); s = Console.ReadLine(); Basic = int.Parse(s); Console.Write("Enter Your PF : "); s = Console.ReadLine(); pf = int.Parse(s); Console.Write("Enter Your Loan : "); s = Console.ReadLine(); loan = int.Parse(s); Console.Write("Enter Your HRA : "); s = Console.ReadLine(); hra = int.Parse(s); Console.Write("Enter Your TA : "); s = Console.ReadLine();

ta = int.Parse(s); }

public void calculate() { allow=Basic+hra+ta; detections=pf+loan; Net=allow-detections; if (Net >= 60000) position = "MANAGER"; else if (Net >= 50000) position = "SUPER VISER"; else position = "EMPLOYEE"; }

public void display() { Console.Write("\n{0}\t{1}\t{2}\t{3}\t\"{4}\"", Name,id,Basic,Net,position); } };

static void Main(string[] args) { int i,n; string s; employee []e = new employee[10]; Console.Write("Enter Total Employees : "); s=Console.ReadLine(); n=int.Parse(s);

for (i = 0; i < n; i++) { e[i].input(); e[i].calculate(); } Console.Write("\n\tPAYBILL GENERATION"); Console.Write("\n\n NAME \tID \tBASIC \tNET \tDESGINATION"); for (i = 0; i < n; i++) e[i].display(); Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for the total salary (NET) for N employees. Ex No: 16 11-07-2012 MULTIPLICATION TABLE

AIM: To write a console application for print the multiplication table for three, four and seven.

ALGORITHM:

Step 1 : START Step 2 : Declare 3 arrays called three, four, seven and initialize the arrays Step 3 : Using foreach loop for display the 3rd ,4th and 7th Multiplication Table Step 4 : STOP

CODING:

using System; using System.Collections.Generic;

using System.Text;

namespace Multiplication_table { class Program { static void Main(string[] args) { int[] three = new int[] { 3, 6, 9, 12, 15, 18, 21, 24, 27, 30 }; int[] four = new int[] { 4, 6, 12, 16, 20, 24, 28, 32, 36, 40 }; int[] seven = new int[] { 7, 14, 21, 28, 35, 42, 49, 56, 63, 70 }; int i = 0; Console.Write("Multiple Tables....."); Console.Write("\n\nTHREE\n"); foreach(Object k in three) { Console.Write("\n{0} * 3 = {1}",i+1,k); i++; } i = 0; Console.Write("\n\nFOUR\n"); foreach (Object k in four) { Console.Write("\n{0} * 4 = {1}", i + 1, k); i++; } i = 0; Console.Write("\n\nSEVEN\n"); foreach (Object k in seven) {

Console.Write("\n{0} * 7 = {1}", i + 1, k); i++; } Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for print the multiplication table for three, four and seven. Ex No: 17 11-07-2012 PATTERN OF WORD MATCHING

AIM: To write a console application for calculate the total and and from in the given sentence.

ALGORITHM:

Step 1 : START Step 2 : Declare 2 arrays called and & from and also initialize the arrays Step 3 : Get the String for calculate the words Step 4 : Using foreach loop for count the and & from in the entered string Step 5 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Word_Matching

{ class Program { static void Main(string[] args) { String s; String[] and ={"and","And","AND"}; String[] from = {"from","From","FROM"}; int Count1=0,Count2=0; Console.Write("Enter a String : "); s = Console.ReadLine(); String[] given = s.Split(); foreach (String i in given) { foreach (String j in and) if (i == j) Count1+=1; foreach (String j in from) if (i == j) Count2+=1; } Console.WriteLine("\nAnd = {0}\nFrom = {1}", Count1, Count2); Console.ReadKey(); } } }

OUTPUT:

RESULT:

Finally a console application is created for calculate the total and and from in the given sentence. Ex No: 18 11-07-2012 SALES IN STATIONARY SHOP

AIM: To write a console application for calculate the bill amount in a stationary shop.

ALGORITHM:

Step 1 : START Step 2 : Create a class called stationary with suitable variables, methods and Constructor Step 3 : Create Object for stationary with connstructor Step 4 : Call input for get inputs

Step 5 : Call Calculate for calculating total amount for all items Step 6 : Display the total bill amount Step 7 : STOP

CODING:

using System; using System.Collections.Generic; using System.Text;

namespace Stationary_Shop { class Program { static void Main(string[] args) { stationary s=new stationary(10,5,10,50,0); s.Input(); s.Calculate(); s.Display(); Console.ReadKey(); } } class stationary { String[] items=new String[4]{"Pen","Pencil","Paper","Note"}; int[] prize=new int[4]; int[] Qty=new int[4]; int[] total=new int[4]; int Total=0;

public stationary(int a,int b,int c,int d,int e) { prize[0]=a; prize[1]=b; prize[2]=c; prize[3]=d; for (int i = 0; i < 4;i++ ) Qty[i] = e; } public void Input() { string s; Console.Write("\nEnter the Following Quantity....\n ");

Console.Write("\nPen,Pencil,Paper,Note : "); for(int i=0;i<4;i++) { s=Console.ReadLine(); Qty[i]=int.Parse(s); } }

public void Calculate() { for(int i=0;i<4;i++) { total[i]=Qty[i]*prize[i]; Total+=total[i]; }

public void Display() { Console.Write("\n\t\t\"\"Bill\"\"\n"); Console.Write("\nItem Name\tPrize\tQuantity\tTotal\n"); for(int i=0;i<4;i++) Console.Write("\n{0}\t\t{1}\t{2}\t\t{3}",items[i],prize[i],Qty[i],total[i]); Console.WriteLine("\n\n Total Bill Amount is {0} Rupees ", Total); } }

OUTPUT:

RESULT:

Finally a console application is created for calculate the bill amount in a stationary shop.