SlideShare a Scribd company logo
STAR ACADEMY OF TECHNOLOGY AND MANAGEMENT
INDORE
COMPUTER SCIENCE & ENGINEERING
DOTNET TECNOLOGY(CS-406)
LAB MANUAL
Submitted By :
Name : RANJIT KUMAR NAHAK
Session : Jan 2014-Jun 2014
Dept. : CSE, SATM
1) W.A.P to perform basic arithmetic calculation.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace add
{
class Program
{
static void Main(string[] args)
{
int a, b;
Console.WriteLine("Enter first nos.");
a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter second no.");
b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("add is :{0}", a + b);
Console.WriteLine("sub is :{0}",a-b);
Console.WriteLine("multiis :{0}",a*b);
Console.WriteLine("devi is :{0}",a/b);
Console.ReadLine();
}
}
}
OUTPUT
2) W.A.P to interchange the value of 2 variables without using third variable.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace swap
{
class Program
{
static void Main(string[] args)
int a = 6;
int b = 7;
Console.WriteLine("the numbers before swapping a={0} and b={1}",a,b);
a = a + b;
b = a - b;
a = a - b;
Console.WriteLine("the numbers after swapping a={0} and b={1}", a,
b); Console.Read();
}
}
}
OUTPUT
3) W.A.P to display array elements & their sum.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace array
{
class Program
{
static void Main(string[] args)
{
int[] num = { 10, 20, 30, 40 }; int n =
num.Length; Console.WriteLine("array
elements"); for (int i = 0; i < n; i++)
{ Console.WriteLine(num[i]);
}
int sum = 0;
for (int i = 0; i < n; i++)
{ sum = sum + num[i];
} Console.WriteLine("sum"+sum);
Console.Read();
}
}
}
OUTPUT
4) W.A.P to input array elements & sort them.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace arrayip
{
class Program
{
static void Main(string[] args)
int i, j, temp;
int[] ar = new int[5];
Console.WriteLine("Enter the elements of array");
for (i = 0; i < ar.Length; i++)
{
ar[i] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("Sorted array is: ");
{
for (i = 0; i < ar.Length; i++)
{
for (j = i + 1; j < ar.Length; j++)
{
if (ar[i] > ar[j])
{
temp = ar[i]; ar[i] =
ar[j]; ar[j] = temp;
}
}
}
for (i = 0; i < ar.Length; i++)
{
Console.Write(ar[i]);
Console.ReadLine();
}
}
}
}}
OUTPUT
5) W.A.P using c lass.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace
{
class Program
{
class student
{
String nm, dep, gen;
public void setdata()
{
Console.WriteLine("Eter Name"); nm =
Console.ReadLine();
Console.WriteLine("Enter Dept"); dep =
Console.ReadLine();
Console.WriteLine("Enter gender"); gen =
Console.ReadLine();
}
public void putdata()
{
Console.WriteLine("Name " +nm);
Console.WriteLine("DEPT " +dep);
Console.WriteLine("Gender " +gen);
}
}
static void Main(string[] args)
{
student stu = new student();
stu.setdata(); stu.putdata();
Console.ReadLine();
}
}
}
OUTPUT
6) W.A.P to print fibonacci series.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace fibonic_series
{
class Program
{
static void Main(string[] args)
{
int a, b, c,n;
a=0;
b=1;
Console.WriteLine("Enter Limit: ");
n =
Convert.ToInt32(Console.ReadLi
ne()); Console.WriteLine( a);
Console.WriteLine( b);
for(int i=3;i<=n;i++)
{
c = a + b;
a = b; b = c;
Console.Writ
eLine(c);
}
Console.ReadLine();
}
}
}
OUTPUT
7) W.A.P using function overloading.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace funover
{
class Program
{
class worker
{
public void salary(int a, int b)
{
int total, bonus;
Console.Write("Enter first bonus: ");
bonus = Convert.ToInt32(Console.ReadLine());
total = bonus + a + b; Console.WriteLine();
Console.WriteLine("Total salary is: "+total);
Console.WriteLine();
}
public void salary(int a)
{
int total, bonus;
Console.Write("Enter second bonus: ");
bonus = Convert.ToInt32(Console.ReadLine());
total = bonus + a; Console.WriteLine();
Console.WriteLine("Total salary is: "+total);
}
}
static void Main(string[] args)
{
worker w = new worker();
w.salary(5000,6000);
w.salary(10000);
Console.ReadLine();
}
}
}
OUTPUT
8) W.A.P to show multilevel inheritance.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace multiinhrit
{
class Area
{
public int l, b;
public void cal_area()
{
Console.WriteLine();
Console.WriteLine("The area is:(l*b) " + (l * b));
}
}
class volume : Area
{
public int h;
public void cal_volume()
{
Console.WriteLine();
Console.WriteLine("The volume is: " + (l * b * h));
}
}
class density : volume
{
int m;
public density(int ll, int bb, int hh, int mm)
{
l = ll;
b = bb;
h = hh;
m = mm;
}
public void cal_density()
{
int d;
d = m / (l * b * h); Console.WriteLine();
Console.WriteLine("The density is: " + d);
}
public void showdata()
{
Console.WriteLine("The length is: " + l);
Console.WriteLine();
Console.WriteLine("The breadth is: " + b);
Console.WriteLine();
Console.WriteLine("The height is: " + h);
Console.WriteLine();
Console.WriteLine("The mass is: " + m);
}
}
class Program
{
static void Main(string[] args)
density dense = new density(12,10,5,4000);
dense.showdata();
dense.cal_volume();
dense.cal_area();
dense.cal_
density();
Console.R
ead();
}
}
}
OUTPUT
9) W.A.P to print star pyramid.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace star
{
class Program
{
static void Main(string[] args)
{
int i,j;
Console.WriteLine("pyramid of star:");
for (i = 0; i <= 5; i++)
{
for (j = 0; j < i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}
OUTPUT
WINDOWS PROGRAMMING
10) W.a.P to print the factorial of a given no.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace fact
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int n,i,fact=1;
n = Convert.ToInt32(textBox1.Text);
for (i = 1; i <= n; i++)
{
fact = fact * i;
}
textBox2.Text = Convert.ToString(fact);
}
OUTPUT
11) W.A.P to find the greatest of three nos.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace greatest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int a, b, c;
a = Convert.ToInt32(textBox1.Text);
b = Convert.ToInt32(textBox2.Text);
c = Convert.ToInt32(textBox3.Text);
if (a > b && a > c)
{
MessageBox.Show("A is Greatest");
}
else
{
if (b > c)
{
MessageBox.Show("B is Gratest");
}
else
{
MessageBox.Show("C is Greatest");
}
}
textBox1.Text
= "";
textBox2.Text
= "";
textBox3.Text
= "";
}
}
}
OUTPUT
12) W.A.P to display calculator.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace calc
{
public partial class Form1 : Form
{
String str = "";//globally
String str1 = "";
Double i, j, k,flag=0;
public Form1()
{
InitializeComponent();
}
private void button16_Click(object sender, EventArgs e)
{
textBox1.Text = " ";
textBox2.Text = " ";
str = "";
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text =str+ "1";
str = textBox1.Text;
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text =str+ "2";
str = textBox1.Text;
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text = str+"3";
str = textBox1.Text;
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text = str+"4";
str = textBox1.Text;
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text = str+"5";
str = textBox1.Text;
}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text = str+"6";
str = textBox1.Text;
}
private void button7_Click(object sender, EventArgs e)
{
textBox1.Text = str+"7";
str = textBox1.Text;
}
private void button8_Click(object sender, EventArgs e)
{
textBox1.Text = str+"8";
str = textBox1.Text;
}
private void button9_Click(object sender, EventArgs e)
{
textBox1.Text = str+"9";
str = textBox1.Text;
}
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text = str+"0";
str = textBox1.Text;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button11_Click(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text;
textBox1.Text = "";
str = "";
str1 = "+";
}
private void button15_Click(object sender, EventArgs e)
{
i = Convert.ToDouble(textBox2.Text);
j = Convert.ToDouble(textBox1.Text);
if (str1 == "+")
k = i + j;
if (str1 == "-")
k = i - j;
if (str1 == "*")
k = i * j;
if (str1 == "/")
k = i / j;
if (str1 == "%")
k = i % j;
textBox1.Text = k.ToString();
}
private void button12_Click(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text;
textBox1.Text = "";
str = "";
str1 = "-";
}
private void button13_Click(object sender, EventArgs e)
textBox2.Text = textBox1.Text;
str = "";
str1 = "*";
}
private void button14_Click(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text;
textBox1.Text = "";
str = "";
str1 = "/";
}
private void button20_Click(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text;
textBox1.Text = "";
str = "";
str1 = "%";
}
private void button18_Click(object sender, EventArgs e)
{
this.Close();
}
private void button17_Click(object sender, EventArgs e)
{
if (flag == 0)
{
textBox1.Text = str + ".";
str = textBox1.Text;
flag = 1;
}
else
{ str = textBox1.Text;
}
}
Dotnet 18
13) W.A.P. for Notepad.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace notepad
public partial class Form1 : Form
)
{
public Form1()
{
InitializeComponent();
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
//Shows the openFileDialog
openFileDialog1.ShowDialog();
//Reads the text file
System.IO.StreamReader OpenFile = new
System.IO.StreamReader(openFileDialog1.FileName);
//Displays the text file in the textBox
txtMain.Text = OpenFile.ReadToEnd();
//Closes the proccess
OpenFile.Close();
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
//Determines the text file to save to
System.IO.StreamWriterSaveFile = new
System.IO.StreamWriter(openFileDialog1.FileName);
//Writes the text to the file
SaveFile.WriteLine(txtMain.Text);
//Closes the proccess
SaveFile.Close();
}
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
//Open the saveFileDialog saveFileDialog1.ShowDialog();
//Determines the text file to save to
System.IO.StreamWriterSaveFile = new
System.IO.StreamWriter(saveFileDialog1.FileName);
//Writes the text to the file
SaveFile.WriteLine(txtMain.Text);
//Closes the process
txtMain.Undo();
}
private void redoToolStripMenuItem_Click(object sender, EventArgs e)
{
txtMain.Undo();
}
private void newToolStripMenuItem_Click(object sender, EventArgs
SaveFile.Close();
}
private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
//Declare prntDoc as a new PrintDocument
printDialog1.ShowDialog();
System.Drawing.Printing.PrintDocument prntDoc =
new
System.Drawing.Printing.PrintDocument();
}
private void printPreviewToolStripMenuItem_Click(object sender, EventArgs
e)
{
printPreviewDialog1.ShowDialog();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void undoToolStripMenuItem_Click(object sender, EventArgs e)
{
e)
{
txtMain.Clear();
}
private void cutToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
txtMain.Copy();
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
{
txtMain.Paste();
}
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
{
txtMain.SelectAll();
}
}
}
Dotnet 18
Dotnet 18

More Related Content

PDF
Writing Domain-Specific Languages for BeepBeep
PPTX
Apache Flink Training: DataSet API Basics
PPTX
Apache Flink Training: DataStream API Part 2 Advanced
PPTX
Modern technologies in data science
PDF
Python Performance 101
PDF
Wprowadzenie do technologi Big Data i Apache Hadoop
PPTX
Optimizing Tcl Bytecode
PPS
Making an Object System with Tcl 8.5
Writing Domain-Specific Languages for BeepBeep
Apache Flink Training: DataSet API Basics
Apache Flink Training: DataStream API Part 2 Advanced
Modern technologies in data science
Python Performance 101
Wprowadzenie do technologi Big Data i Apache Hadoop
Optimizing Tcl Bytecode
Making an Object System with Tcl 8.5

What's hot (20)

PDF
C# 7.x What's new and what's coming with C# 8
PPTX
Poor Man's Functional Programming
PDF
delegates
PDF
The Ring programming language version 1.5.2 book - Part 7 of 181
PDF
Core java pract_sem iii
PDF
Martin Fowler's Refactoring Techniques Quick Reference
PDF
Refactoring to Macros with Clojure
PDF
Odessapy2013 - Graph databases and Python
PDF
Java8 stream
PDF
DCN Practical
PPTX
JavaScript Event Loop
PPSX
Scala @ TomTom
PDF
NLP on a Billion Documents: Scalable Machine Learning with Apache Spark
PPTX
Collection
PDF
Programming with Python and PostgreSQL
DOCX
Java programs
PDF
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
DOCX
java experiments and programs
PDF
If You Think You Can Stay Away from Functional Programming, You Are Wrong
C# 7.x What's new and what's coming with C# 8
Poor Man's Functional Programming
delegates
The Ring programming language version 1.5.2 book - Part 7 of 181
Core java pract_sem iii
Martin Fowler's Refactoring Techniques Quick Reference
Refactoring to Macros with Clojure
Odessapy2013 - Graph databases and Python
Java8 stream
DCN Practical
JavaScript Event Loop
Scala @ TomTom
NLP on a Billion Documents: Scalable Machine Learning with Apache Spark
Collection
Programming with Python and PostgreSQL
Java programs
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
java experiments and programs
If You Think You Can Stay Away from Functional Programming, You Are Wrong
Ad

Viewers also liked (19)

PDF
Etón Soulra
PPTX
La carta de un ángel a sus seres
PPTX
Memoràndum
DOC
Sankt Peter LifePR.doc
DOC
23-11-2011 El Gobernador Guillermo Padrés inauguró la pavimentación de calles...
DOCX
Fuga projeto
PDF
Turbofan Motorlar
PPTX
La mujer en la sagrada escritura
PDF
Full Page Fax Print2
PPT
Tidewater Consortium, 22 July 09
DOC
Double page annotated
PDF
Lithuanian Economy - No 1, January 4, 2012
PDF
Talking points for the high level youth policy dialogue on sustainable develo...
PPTX
There Is No Agile
PDF
Hasil Kelompok I
PPT
What makes indicators successful? Lessons from practitioners
PDF
Normativa - JJFF RITSI 2014
PDF
Están atentos a la lectura de un cuento
PPTX
Proverbs 1b seek wisdom from god
Etón Soulra
La carta de un ángel a sus seres
Memoràndum
Sankt Peter LifePR.doc
23-11-2011 El Gobernador Guillermo Padrés inauguró la pavimentación de calles...
Fuga projeto
Turbofan Motorlar
La mujer en la sagrada escritura
Full Page Fax Print2
Tidewater Consortium, 22 July 09
Double page annotated
Lithuanian Economy - No 1, January 4, 2012
Talking points for the high level youth policy dialogue on sustainable develo...
There Is No Agile
Hasil Kelompok I
What makes indicators successful? Lessons from practitioners
Normativa - JJFF RITSI 2014
Están atentos a la lectura de un cuento
Proverbs 1b seek wisdom from god
Ad

Similar to Dotnet 18 (20)

DOCX
PDF
This is a C# project . I am expected to create as this image shows. .pdf
DOCX
.net progrmming part1
PDF
C# Program. Create a Windows application that has the functionality .pdf
DOCX
Oops pramming with examples
PPT
Csphtp1 06
PPTX
C#.net
PDF
Object oriented programming
PDF
lab.123456789123456789123456789123456789
 
PPTX
unsplitted slideshare
DOCX
C# labprograms
PDF
Lesson 2 Understanding Types And Usage In Dot Net
PDF
Functional programming basics
PPTX
C# basics
PPTX
Ensure code quality with vs2012
PPTX
Spf Chapter4 Variables
PDF
C sharp chap6
DOCX
Write and write line methods
DOCX
Net practicals lab mannual
This is a C# project . I am expected to create as this image shows. .pdf
.net progrmming part1
C# Program. Create a Windows application that has the functionality .pdf
Oops pramming with examples
Csphtp1 06
C#.net
Object oriented programming
lab.123456789123456789123456789123456789
 
unsplitted slideshare
C# labprograms
Lesson 2 Understanding Types And Usage In Dot Net
Functional programming basics
C# basics
Ensure code quality with vs2012
Spf Chapter4 Variables
C sharp chap6
Write and write line methods
Net practicals lab mannual

Recently uploaded (20)

PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Complications of Minimal Access Surgery at WLH
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
Pharma ospi slides which help in ospi learning
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
Cell Types and Its function , kingdom of life
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
Classroom Observation Tools for Teachers
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
TR - Agricultural Crops Production NC III.pdf
O7-L3 Supply Chain Operations - ICLT Program
Complications of Minimal Access Surgery at WLH
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
STATICS OF THE RIGID BODIES Hibbelers.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Week 4 Term 3 Study Techniques revisited.pptx
Pharma ospi slides which help in ospi learning
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Cell Types and Its function , kingdom of life
Microbial diseases, their pathogenesis and prophylaxis
2.FourierTransform-ShortQuestionswithAnswers.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Microbial disease of the cardiovascular and lymphatic systems
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Basic Mud Logging Guide for educational purpose
Classroom Observation Tools for Teachers
FourierSeries-QuestionsWithAnswers(Part-A).pdf
TR - Agricultural Crops Production NC III.pdf

Dotnet 18

  • 1. STAR ACADEMY OF TECHNOLOGY AND MANAGEMENT INDORE COMPUTER SCIENCE & ENGINEERING DOTNET TECNOLOGY(CS-406) LAB MANUAL Submitted By : Name : RANJIT KUMAR NAHAK Session : Jan 2014-Jun 2014 Dept. : CSE, SATM
  • 2. 1) W.A.P to perform basic arithmetic calculation. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace add { class Program { static void Main(string[] args) { int a, b; Console.WriteLine("Enter first nos."); a = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter second no."); b = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("add is :{0}", a + b); Console.WriteLine("sub is :{0}",a-b); Console.WriteLine("multiis :{0}",a*b); Console.WriteLine("devi is :{0}",a/b); Console.ReadLine(); } } }
  • 4. 2) W.A.P to interchange the value of 2 variables without using third variable. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace swap { class Program { static void Main(string[] args) int a = 6; int b = 7; Console.WriteLine("the numbers before swapping a={0} and b={1}",a,b); a = a + b; b = a - b; a = a - b; Console.WriteLine("the numbers after swapping a={0} and b={1}", a, b); Console.Read(); } } }
  • 6. 3) W.A.P to display array elements & their sum. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace array { class Program { static void Main(string[] args) { int[] num = { 10, 20, 30, 40 }; int n = num.Length; Console.WriteLine("array elements"); for (int i = 0; i < n; i++) { Console.WriteLine(num[i]); } int sum = 0; for (int i = 0; i < n; i++) { sum = sum + num[i]; } Console.WriteLine("sum"+sum); Console.Read(); } } }
  • 8. 4) W.A.P to input array elements & sort them. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace arrayip { class Program { static void Main(string[] args) int i, j, temp; int[] ar = new int[5]; Console.WriteLine("Enter the elements of array"); for (i = 0; i < ar.Length; i++) { ar[i] = Convert.ToInt32(Console.ReadLine()); } Console.WriteLine("Sorted array is: "); { for (i = 0; i < ar.Length; i++) { for (j = i + 1; j < ar.Length; j++) { if (ar[i] > ar[j]) { temp = ar[i]; ar[i] = ar[j]; ar[j] = temp; } } } for (i = 0; i < ar.Length; i++) { Console.Write(ar[i]); Console.ReadLine(); } } } }}
  • 10. 5) W.A.P using c lass. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace { class Program { class student { String nm, dep, gen; public void setdata() { Console.WriteLine("Eter Name"); nm = Console.ReadLine(); Console.WriteLine("Enter Dept"); dep = Console.ReadLine(); Console.WriteLine("Enter gender"); gen = Console.ReadLine(); } public void putdata() { Console.WriteLine("Name " +nm); Console.WriteLine("DEPT " +dep); Console.WriteLine("Gender " +gen); } } static void Main(string[] args) { student stu = new student(); stu.setdata(); stu.putdata(); Console.ReadLine(); } } }
  • 12. 6) W.A.P to print fibonacci series. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace fibonic_series { class Program { static void Main(string[] args) { int a, b, c,n; a=0; b=1; Console.WriteLine("Enter Limit: "); n = Convert.ToInt32(Console.ReadLi ne()); Console.WriteLine( a); Console.WriteLine( b); for(int i=3;i<=n;i++) { c = a + b; a = b; b = c; Console.Writ eLine(c); } Console.ReadLine(); } } }
  • 14. 7) W.A.P using function overloading. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace funover { class Program { class worker { public void salary(int a, int b) { int total, bonus; Console.Write("Enter first bonus: "); bonus = Convert.ToInt32(Console.ReadLine()); total = bonus + a + b; Console.WriteLine(); Console.WriteLine("Total salary is: "+total); Console.WriteLine(); } public void salary(int a) { int total, bonus; Console.Write("Enter second bonus: "); bonus = Convert.ToInt32(Console.ReadLine()); total = bonus + a; Console.WriteLine(); Console.WriteLine("Total salary is: "+total); } } static void Main(string[] args) { worker w = new worker(); w.salary(5000,6000); w.salary(10000); Console.ReadLine(); } }
  • 16. 8) W.A.P to show multilevel inheritance. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace multiinhrit { class Area { public int l, b; public void cal_area() { Console.WriteLine(); Console.WriteLine("The area is:(l*b) " + (l * b)); } } class volume : Area { public int h; public void cal_volume() { Console.WriteLine(); Console.WriteLine("The volume is: " + (l * b * h)); } } class density : volume { int m; public density(int ll, int bb, int hh, int mm) { l = ll; b = bb; h = hh; m = mm; } public void cal_density() { int d; d = m / (l * b * h); Console.WriteLine(); Console.WriteLine("The density is: " + d); }
  • 17. public void showdata() { Console.WriteLine("The length is: " + l); Console.WriteLine(); Console.WriteLine("The breadth is: " + b); Console.WriteLine(); Console.WriteLine("The height is: " + h); Console.WriteLine(); Console.WriteLine("The mass is: " + m); } } class Program { static void Main(string[] args) density dense = new density(12,10,5,4000); dense.showdata(); dense.cal_volume(); dense.cal_area(); dense.cal_ density(); Console.R ead(); } } }
  • 19. 9) W.A.P to print star pyramid. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace star { class Program { static void Main(string[] args) { int i,j; Console.WriteLine("pyramid of star:"); for (i = 0; i <= 5; i++) { for (j = 0; j < i; j++) { Console.Write("*"); } Console.WriteLine(); } Console.ReadLine(); } } }
  • 21. 10) W.a.P to print the factorial of a given no. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace fact { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int n,i,fact=1; n = Convert.ToInt32(textBox1.Text); for (i = 1; i <= n; i++) { fact = fact * i; } textBox2.Text = Convert.ToString(fact); }
  • 23. 11) W.A.P to find the greatest of three nos. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace greatest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int a, b, c; a = Convert.ToInt32(textBox1.Text); b = Convert.ToInt32(textBox2.Text); c = Convert.ToInt32(textBox3.Text); if (a > b && a > c) { MessageBox.Show("A is Greatest"); } else { if (b > c) { MessageBox.Show("B is Gratest"); } else { MessageBox.Show("C is Greatest"); } } textBox1.Text
  • 26. 12) W.A.P to display calculator. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace calc { public partial class Form1 : Form { String str = "";//globally String str1 = ""; Double i, j, k,flag=0; public Form1() { InitializeComponent(); } private void button16_Click(object sender, EventArgs e) { textBox1.Text = " "; textBox2.Text = " "; str = ""; } private void button1_Click(object sender, EventArgs e) { textBox1.Text =str+ "1"; str = textBox1.Text; } private void button2_Click(object sender, EventArgs e) {
  • 27. textBox1.Text =str+ "2"; str = textBox1.Text; } private void button3_Click(object sender, EventArgs e) { textBox1.Text = str+"3"; str = textBox1.Text; } private void button4_Click(object sender, EventArgs e) { textBox1.Text = str+"4"; str = textBox1.Text; } private void button5_Click(object sender, EventArgs e) { textBox1.Text = str+"5"; str = textBox1.Text; } private void button6_Click(object sender, EventArgs e) { textBox1.Text = str+"6"; str = textBox1.Text; } private void button7_Click(object sender, EventArgs e) { textBox1.Text = str+"7"; str = textBox1.Text; } private void button8_Click(object sender, EventArgs e) { textBox1.Text = str+"8"; str = textBox1.Text; }
  • 28. private void button9_Click(object sender, EventArgs e) { textBox1.Text = str+"9"; str = textBox1.Text; } private void button10_Click(object sender, EventArgs e) { textBox1.Text = str+"0"; str = textBox1.Text; } private void Form1_Load(object sender, EventArgs e) { } private void button11_Click(object sender, EventArgs e) { textBox2.Text = textBox1.Text; textBox1.Text = ""; str = ""; str1 = "+"; } private void button15_Click(object sender, EventArgs e) { i = Convert.ToDouble(textBox2.Text); j = Convert.ToDouble(textBox1.Text); if (str1 == "+") k = i + j; if (str1 == "-") k = i - j; if (str1 == "*") k = i * j; if (str1 == "/") k = i / j; if (str1 == "%") k = i % j; textBox1.Text = k.ToString(); }
  • 29. private void button12_Click(object sender, EventArgs e) { textBox2.Text = textBox1.Text; textBox1.Text = ""; str = ""; str1 = "-"; } private void button13_Click(object sender, EventArgs e) textBox2.Text = textBox1.Text; str = ""; str1 = "*"; } private void button14_Click(object sender, EventArgs e) { textBox2.Text = textBox1.Text; textBox1.Text = ""; str = ""; str1 = "/"; } private void button20_Click(object sender, EventArgs e) { textBox2.Text = textBox1.Text; textBox1.Text = ""; str = ""; str1 = "%"; } private void button18_Click(object sender, EventArgs e) { this.Close(); } private void button17_Click(object sender, EventArgs e) { if (flag == 0) { textBox1.Text = str + ".";
  • 30. str = textBox1.Text; flag = 1; } else { str = textBox1.Text; } }
  • 32. 13) W.A.P. for Notepad. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace notepad public partial class Form1 : Form ) { public Form1() { InitializeComponent(); } private void openToolStripMenuItem_Click(object sender, EventArgs e) { //Shows the openFileDialog openFileDialog1.ShowDialog(); //Reads the text file System.IO.StreamReader OpenFile = new System.IO.StreamReader(openFileDialog1.FileName); //Displays the text file in the textBox txtMain.Text = OpenFile.ReadToEnd(); //Closes the proccess OpenFile.Close(); } private void saveToolStripMenuItem_Click(object sender, EventArgs e) { //Determines the text file to save to System.IO.StreamWriterSaveFile = new System.IO.StreamWriter(openFileDialog1.FileName);
  • 33. //Writes the text to the file SaveFile.WriteLine(txtMain.Text); //Closes the proccess SaveFile.Close(); } private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) { //Open the saveFileDialog saveFileDialog1.ShowDialog(); //Determines the text file to save to System.IO.StreamWriterSaveFile = new System.IO.StreamWriter(saveFileDialog1.FileName); //Writes the text to the file SaveFile.WriteLine(txtMain.Text); //Closes the process txtMain.Undo(); } private void redoToolStripMenuItem_Click(object sender, EventArgs e) { txtMain.Undo(); } private void newToolStripMenuItem_Click(object sender, EventArgs SaveFile.Close(); } private void printToolStripMenuItem_Click(object sender, EventArgs e) { //Declare prntDoc as a new PrintDocument printDialog1.ShowDialog(); System.Drawing.Printing.PrintDocument prntDoc = new System.Drawing.Printing.PrintDocument(); } private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e) { printPreviewDialog1.ShowDialog();
  • 34. } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit(); } private void undoToolStripMenuItem_Click(object sender, EventArgs e) { e) { txtMain.Clear(); } private void cutToolStripMenuItem_Click(object sender, EventArgs e) { } private void copyToolStripMenuItem_Click(object sender, EventArgs e) { txtMain.Copy(); } private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { txtMain.Paste(); } private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) { txtMain.SelectAll(); } } }