1-Program To Addition, Subtraction, Multipication, Division: Output
1-Program To Addition, Subtraction, Multipication, Division: Output
1-Program To Addition, Subtraction, Multipication, Division: Output
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace add_mul_sum_div
{
class Program
{
static void Main(string[] args)
{
int a, b;
a = 10;
b = 4;
Console.WriteLine("Addition={0}", a + b);
Console.WriteLine("Subtraction={0}", a - b);
Console.WriteLine("Multiply={0}", a * b);
Console.WriteLine("Division={0}",(float)a / b);
}
}
}
Output :
Output :
Output :
Output :
Output :
6 PROGRAM TO FACTORIAL OF N
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dynamic_Factorial
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the number: ");
int a = Convert.ToInt32(Console.ReadLine());
int result= fact(a);
Console.WriteLine("Factorial of the number is: " + result);
}
static int fact(int b)
{
if(b <= 1)
return 1;
else
return b * fact(b-1);
}
}
}
Output :
7 PROGRAM TO TRAINGALE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Triangle
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter the charecter\n");
string str1 = Console.ReadLine();
int i = 0;
char[] arr = new char[10];
foreach (char s in str1)
arr[i++] = s;
for (i = 0; i < str1.Length; i++)
{
for (int j = 0; j <= i; j++)
Console.Write(arr[j]);
Console.ReadLine();
}
}
}
}
Output :
Console.Write(j);
}
Console.WriteLine();
}
}
}
class Program
{
static void Main(string[] args)
{
C obj = new C();
obj.Nand();
obj.Saxena();
obj.Bramha();
Console.Read();
}
}
}
Output :
9 PROGRAM TO INTERFACE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace interface_me
{
interface A
{
void me();
}
interface B
{
void show();
}
class C : B, A
{
public void me()
{
Console.WriteLine("I LOVE MY India");
}
public void show()
{
Console.WriteLine("My Name is B.N.Saxena");
}
}
class Program
{
static void Main(string[] args)
{
C obj = new C();
obj.me();
obj.show();
Console.Read();
}
}}
Output :
10
Output :
11
Output :
12
12 PROGRAM TO ABSTRACT
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace abstracclass
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Abstrt
{
abstract class GN
{
public abstract void nand();
public abstract void show();
}
class BN : GN
{
int i, j;
public override void nand()
{
Console.WriteLine("THis is Solution");
}
public override void show()
{
for (i = 5; i >= 0; i--)
{
for (j = 0; j <= i; j++)
{
Console.Write(i);
}
Console.WriteLine();
}
}
}
class ZN : BN
{
int x, y;
public override void nand()
{
x = 12;
y = 11;
}
13
Output :
14
15
Output :
16
Output :
17
Output :
18
16 - PROGRAM TO 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 Excel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Label l;
Label p;
Label q;
TextBox t;
TextBox r;
TextBox s;
private void Form1_Load(object sender, EventArgs e)
{
l = new Label();
l.Location = new Point(100, 70);
l.Text=("Value1");
Controls.Add(l);
p = new Label();
p.Location = new Point(100, 110);
p.Text = ("Value2");
Controls.Add(p);
q = new Label();
q.Location = new Point(100, 150);
q.Text = ("Result");
Controls.Add(q);
t = new TextBox();
t.Location = new Point(200, 70);
t.Text = (" ");
Controls.Add(t);
r = new TextBox();
19
Output :
21
Output :
22
tbrate.Text = Convert.ToString(100);
else if (listBox1.SelectedItem.ToString() == "IDLI")
tbrate.Text = Convert.ToString(60);
else if (listBox1.SelectedItem.ToString() == "DOSHA")
tbrate.Text = Convert.ToString(70);
else
tbrate.Text = string.Empty;
}
private void button1_Click(object sender, EventArgs e)
{
if (tbamount.Text != "")
listBox2.Items.Add(tbamount.Text);
else
MessageBox.Show("Please first calculate amount");
}
private void button2_Click(object sender, EventArgs e)
{
int sum = 0;
foreach (string n in listBox2.Items)
{
sum = sum + Convert.ToInt32(n);
}
tbtotal.Text = "Rs. "+sum.ToString()+" Only";
}
private void tbqty_TextChanged(object sender, EventArgs e)
{
if (tbqty.Text != "")
{
int a, b, c;
a = Convert.ToInt32(tbrate.Text);
b = Convert.ToInt32(tbqty.Text);
c = a * b;
tbamount.Text = c.ToString();
}
else
tbamount.Text = string.Empty;
}
private void button5_Click(object sender, EventArgs e)
{
tbqty.Text = string.Empty;
tbamount.Text = string.Empty;
listBox2.Items.Clear();
tbtotal.Text = string.Empty;
}
24
Output :
25
18 PROGRAM TO LISTBOX
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 ListBoxDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listBox2.Items.Add(listBox1.SelectedItem.ToString());
listBox1.Items.Remove(listBox1.SelectedItem);
listBox2.Sorted = true;
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Add(listBox2.SelectedItem.ToString());
listBox2.Items.Remove(listBox2.SelectedItem);
}
private void button3_Click(object sender, EventArgs e)
{
foreach(string n in listBox1.Items)
{
listBox2.Items.Add(n.ToString());
}
listBox1.Items.Clear();
}
private void button4_Click(object sender, EventArgs e)
{
foreach (string n in listBox2.Items)
{
listBox1.Items.Add(n.ToString());
}
26
listBox2.Items.Clear();
}
private void Form1_Load(object sender, EventArgs e)
{
listBox1.Sorted = true;
}
}
}
Output :
27
28