syed

311
-1

Published on

Published in: Technology, Spiritual
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
311
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

syed

  1. 1. C# Practical File 2013 By: Syed Mohd Naqi Zaidi using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace neha { class MATRIX { static void Main(string[] str) { Console.WriteLine(" Program to calculate addition of two matrix of size 2*2 "); int[,] m1 = new int[3, 3]; Console.WriteLine(); Console.WriteLine("Enter the Values of 1st matrix : "); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { m1[i, j] = int.Parse(Console.ReadLine()); } } int[,] m2 = new int[3, 3]; Console.WriteLine("Enter the Values of 2nd matrix :"); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { m2[i, j] = int.Parse(Console.ReadLine()); } } int[,] c = new int[3, 3]; Console.WriteLine("The Addtion of Matrix is : "); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { Console.Write((m1[i, j] + m2[i, j]) + " "); } Console.WriteLine(); } Console.ReadLine(); } } } /***WAP to calculate addition of two 2*2 matrix***/
  2. 2. C# Practical File 2013 By: Syed Mohd Naqi Zaidi OUTPUT
  3. 3. C# Practical File 2013 By: Syed Mohd Naqi Zaidi using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace NEHA { class STRING { public static void length() { string s; Console.WriteLine("Enter The String "); s = Console.ReadLine(); Console.WriteLine("Lenght of the String is :" + s.Length); } public static void palindrome() { string str, revstr; Console.WriteLine("Enter Any String to Know It is Palindrome or not"); str = Console.ReadLine(); char[] tempstr = str.ToCharArray(); Array.Reverse(tempstr); revstr = new string(tempstr); bool caseignore = str.Equals(revstr, StringComparison.OrdinalIgnoreCase); if (caseignore == true) { Console.WriteLine("............" + str + " Is a Palindrome.........."); } else { Console.WriteLine("............" + str + " Is Not a Palindrome........"); } } static void Main(string[] args) { length(); palindrome(); Console.ReadLine(); } } } /*** create a class to perform following operations:-  Calculate the length of string.  Check whether the string is a palindrome or not. ***/
  4. 4. C# Practical File 2013 By: Syed Mohd Naqi Zaidi OUTPUT
  5. 5. C# Practical File 2013 By: Syed Mohd Naqi Zaidi using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace neha { class EVENODD { static void Main(string[] str) { Console.WriteLine("Even" + " " + "ODD"); for (int i = 0; i < 50; i++) { if ((i % 2) == 0) Console.Write(i + " "); else { if ((i % 2) != 0) Console.WriteLine(i); } } Console.ReadLine(); } } } /***WAP to generate series of even and odd numbers separately between 1to50***/
  6. 6. C# Practical File 2013 By: Syed Mohd Naqi Zaidi OUTPUT
  7. 7. C# Practical File 2013 By: Syed Mohd Naqi Zaidi
  8. 8. C# Practical File 2013 By: Syed Mohd Naqi Zaidi using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace neha { class FACTORIAL { public static string rev(string st) { char[] ar = st.ToCharArray(); Array.Reverse(ar); return new string(ar); } static int a, b = 1; static string st; static void Main(string[] str) { Console.Write(" Program to Calculate the Factorial, length, Reverse of the string "); Console.WriteLine(); Console.WriteLine(); Console.Write("Enter the any value:"); a = int.Parse(Console.ReadLine()); for (int i = a; i > 1; i--) { b = b * i; } Console.Write("Factorial number: "); Console.WriteLine(b); st = b.ToString(); st = rev(st); Console.Write("Length of string: "); Console.WriteLine(st.Length); Console.Write("Reverse String: "); Console.WriteLine(st); Console.ReadKey(); } } } /***WAP to find the factorial of given integer, inverse of the number, calculate sum of the digits***/
  9. 9. C# Practical File 2013 By: Syed Mohd Naqi Zaidi OUTPUT
  10. 10. C# Practical File 2013 By: Syed Mohd Naqi Zaidi Define a class to represent a bank account having following members name, acc. No, type, initial values deposited amt, withdraw amt and display balance. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text.RegularExpressions; using System.Windows.Forms; using System.Collections; using System.Media; using System.Resources; using System.Reflection; using System.Diagnostics; using System.IO; namespace timer_and_acount_prog { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Form2 frm = new Form2(); private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox3.Text == "" || (!Regex.IsMatch(textBox1.Text, @"[0-9]") || !(Regex.IsMatch(textBox3.Text, @"[0- 9]")))) { MessageBox.Show("Please Enter the integer value in: " + 'n' + 'n' + " ACCOUNT NO. AND TOTAL AMOUNT", "MANI MESSAGE"); } else if (textBox2.Text == "" || textBox4.Text == "" || (!Regex.IsMatch(textBox2.Text, @"[a-zA-Z]") || !(Regex.IsMatch(textBox4.Text, @"[a-zA-Z]")))) { MessageBox.Show("Please Enter the String in: " + Environment.NewLine+'n' + "NAME AND ACCOUNT TYPE", "MANI MESSAGE"); } else { frm.a = int.Parse(textBox1.Text); frm.b = int.Parse(textBox3.Text); frm.d = button1.Text; frm.Show();
  11. 11. C# Practical File 2013 By: Syed Mohd Naqi Zaidi this.Hide(); } } private void button3_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox3.Text == "" || (!Regex.IsMatch(textBox1.Text, @"[0-9]") || !(Regex.IsMatch(textBox3.Text, @"[0- 9]")))) { MessageBox.Show("Please Enter the integer value in: " + 'n' + 'n' + " ACCOUNT NO. AND TOTAL AMOUNT", "MANI MESSAGE"); } else if (textBox2.Text == "" || textBox4.Text == "" || (!Regex.IsMatch(textBox2.Text, @"[a-zA-Z]") || !(Regex.IsMatch(textBox4.Text, @"[a-zA-Z]")))) { MessageBox.Show("Please Enter the String in: "+ Environment.NewLine+'n' +"NAME AND ACCOUNT TYPE", "MANI MESSAGE"); } else { frm.a = int.Parse(textBox1.Text); frm.b = int.Parse(textBox3.Text); frm.d = button3.Text; frm.Show(); this.Hide(); } } private void Form1_Load(object sender, EventArgs e) { } private void button4_Click(object sender, EventArgs e) { this.Close(); } private void button2_Click(object sender, EventArgs e) { MessageBox.Show("Account No.: " + textBox1.Text.ToString() + 'n' + 'n' + "Name Is: " + textBox2.Text + 'n' + 'n' + "Total Amount: " + textBox3.Text.ToString() + 'n' + 'n' + label4.Text + ": " + textBox4.Text, "MANI MESSAGE"); } } } FORM 2 using System;
  12. 12. C# Practical File 2013 By: Syed Mohd Naqi Zaidi using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text.RegularExpressions; using System.Windows.Forms; namespace timer_and_acount_prog { public partial class Form2 : Form { public int a, b, c; public string d,s; public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form1 f = new Form1(); if (textBox5.Text == "" || (!Regex.IsMatch(textBox5.Text,@"[0-9]"))) { MessageBox.Show("Please Enter the integer value"); } else { c = int.Parse(textBox5.Text); if (label5.Text == "Deposit") { textBox2.Text = (b + c).ToString(); } else { if (b > c) { textBox2.Text = (b - c).ToString(); } else MessageBox.Show("Your Amount Is More than total Amount "+'n'+" Your Current Balance is: "+b); } MessageBox.Show("ACCOUNT NO. " + textBox1.Text + " " + " Balance Is " + textBox2.Text, "KALRA BANK ;) :P"); } } private void Form2_Load(object sender, EventArgs e) { Form1 f = new Form1(); f.Hide(); textBox1.Text = a.ToString(); label5.Text = d; label5.Visible = true; textBox5.Visible = true; textBox1.ReadOnly = true; }
  13. 13. C# Practical File 2013 By: Syed Mohd Naqi Zaidi private void button2_Click(object sender, EventArgs e) { Form1 frm = new Form1(); this.Close(); frm.Show(); } } }
  14. 14. C# Practical File 2013 By: Syed Mohd Naqi Zaidi OUTPUT:-
  15. 15. C# Practical File 2013 By: Syed Mohd Naqi Zaidi Swap two values using call by reference . a) Create a method using reference parameter to calculate square of no. b) Create a class by name decompose that separates the integer no and fractional part of given floating point no. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Swap { class Swapping { class Swap { public void swap(ref int a, ref int b) { int t; t = a; a = b; b = t; } static void squareRef(ref int refParameter) { refParameter *= refParameter; } public class SwapDemo { public static void Main() { Swap ob = new Swap(); int x = 10, y = 20; Console.WriteLine("X and Y Before call: " + x + " " + y); ob.swap(ref x, ref y); Console.WriteLine("X and Y After call: " + x + " " + y); int arg; arg = 5; squareRef(ref arg); Console.WriteLine("Square Of a Number is :"+arg); Console.Read(); } } } } }
  16. 16. C# Practical File 2013 By: Syed Mohd Naqi Zaidi

×