Advertisement
Guest User

All c# program

a guest
Dec 7th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.08 KB | None | 0 0
  1. 1.তিনটা সংখ্যার ভিতর বড় সংখ্যা নির্নয় এর c# প্রোগ্রাম লিখ।
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5.  
  6. namespace Program
  7. {
  8.     class Big_number
  9.     {
  10.         static void Main(String[] args)
  11.         {
  12.             int num1, num2, num3;
  13.  
  14.             Console.Write("Enter your first numebr: ");
  15.             num1 =Convert.ToInt32( Console.ReadLine());
  16.  
  17.             Console.Write("Enter your first numebr: ");
  18.             num2 = Convert.ToInt32(Console.ReadLine());
  19.  
  20.             Console.Write("Enter your first numebr: ");
  21.             num3 = Convert.ToInt32(Console.ReadLine());
  22.  
  23.             if (num1 > num2 && num1 > num3)
  24.             {
  25.                 Console.WriteLine("The large number is =" + num1);
  26.             }
  27.             else if (num2 > num1 && num2 > num3)
  28.             {
  29.                 Console.WriteLine("The large number is =" + num2);
  30.             }
  31.             else
  32.             {
  33.                 Console.WriteLine("The large number is =" + num3);
  34.             }
  35.             Console.ReadKey();
  36.         }
  37.     }
  38. }
  39.  
  40. 2.দ্বিঘাত সমীকরণের মূল বের করার জন্য  c# প্রোগ্রাম লিখ।
  41. using System;
  42. using System.Collections.Generic;
  43. using System.Text;
  44.  
  45. namespace Program
  46. {
  47.     class dighat_somikoron
  48.     {
  49.         static void Main(string[] args)
  50.         {
  51.             int a, b, c;
  52.  
  53.             double d, x1, x2;
  54.      
  55.             Console.Write("Input the value of a : ");
  56.             a = Convert.ToInt32(Console.ReadLine());
  57.  
  58.             Console.Write("Input the value of b : ");
  59.             b = Convert.ToInt32(Console.ReadLine());
  60.  
  61.             Console.Write("Input the value of c : ");
  62.             c = Convert.ToInt32(Console.ReadLine());
  63.  
  64.             d = b * b - 4 * a * c;
  65.             if (d == 0)
  66.             {
  67.                 Console.Write("Both roots are equal.\n");
  68.                 x1 = -b / (2.0 * a);
  69.                 x2 = x1;
  70.                 Console.Write("First  Root Root1= {0}\n", x1);
  71.                 Console.Write("Second Root Root2= {0}\n", x2);
  72.             }
  73.             else if (d > 0)
  74.             {
  75.                 Console.Write("Both roots are real and diff-2\n");
  76.  
  77.                 x1 = (-b + Math.Sqrt(d)) / (2 * a);
  78.                 x2 = (-b - Math.Sqrt(d)) / (2 * a);
  79.  
  80.                 Console.Write("First  Root Root1= {0}\n", x1);
  81.                 Console.Write("Second Root root2= {0}\n", x2);
  82.             }
  83.             else
  84.                 Console.Write("Root are imeainary;\nNo Solution. \n\n");
  85.         }
  86.     }
  87. }
  88. . মাল্টিলেভেল ইনহেরিটেন্স ব্যবহার করে  c# প্রোগ্রাম লিখ।
  89. using System;
  90. using System.Collections.Generic;
  91. using System.Text;
  92.  
  93. namespace Program
  94. {
  95.     class A
  96.     {
  97.         public void show()
  98.         {
  99.             Console.WriteLine("Welcome to the world of c#");
  100.         }
  101.     }
  102.     class B : A //class B is derived by class A
  103.     {
  104.         public void display()
  105.         {
  106.             Console.WriteLine("Hello");
  107.         }
  108.     }
  109.     class C : B //class C is derived by class B
  110.     {
  111.         public void show1()
  112.         {
  113.             Console.WriteLine("How are You ?");
  114.         }
  115.  
  116.  
  117.         class Multilevel_inheritench
  118.         {
  119.  
  120.             public static void Main()
  121.             {
  122.                 C obj = new C();
  123.                 obj.show();
  124.                 obj.display();
  125.                 obj.show1();
  126.             }
  127.         }
  128.     }
  129. }
  130.  
  131.  
  132. . ১ থেকে ১০০ পর্যন্ত প্রাই নাম্বার বের করার   c# প্রোগ্রাম লিখ।
  133. using System;
  134. using System.Collections.Generic;
  135. using System.Text;
  136.  
  137. namespace Program
  138. {
  139.     class Prime_Number
  140.     {
  141.         static void Main(String[] args)
  142.         {
  143.             int count = 0,n;
  144.             Console.WriteLine("Prime numbers between 1 and 100 are: ");
  145.        
  146.             for (int i = 1; i < 101; i++)
  147.             {
  148.                 count = 0;
  149.                 if (i > 1)
  150.                 {
  151.                     for (int j = 2; j < i; j++)
  152.                     {
  153.                         if (i % j == 0)
  154.                         {
  155.                             count = 1;
  156.                             break;
  157.                         }
  158.                     }
  159.                     if (count == 0)
  160.                     {
  161.                         Console.Write(i + "  ");
  162.                     }
  163.                 }
  164.             }
  165.         }
  166.     }
  167. }
  168.  
  169. ৫।  array ব্যবহার করে ১০ টি সংখার মাঝে বড় সংখ্যা মাঝে বড় সংখ্যাটি বের করার প্রোগ্রাম।
  170. using System;
  171. using System.Collections.Generic;
  172. using System.Text;
  173.  
  174. namespace Program
  175. {
  176.     class Array
  177.     {
  178.         static void Main(String[] args)
  179.         {
  180.             int i = 0;
  181.             int large = 0;
  182.  
  183.             int[] arr = new int[10];
  184.  
  185.  
  186.             Console.WriteLine("Enter array elements : ");
  187.             for (i = 0; i < arr.Length; i++)
  188.             {
  189.                 Console.Write("Element[" + (i + 1) + "]: ");
  190.                 arr[i] = int.Parse(Console.ReadLine());
  191.             }
  192.  
  193.            
  194.             large = arr[0];
  195.             for (i = 1; i < arr.Length; i++)
  196.             {
  197.                
  198.                 if (large < arr[i])
  199.                     large = arr[i];
  200.             }
  201.            
  202.             Console.WriteLine("Largest element in array : " + large);
  203.         }
  204.     }
  205. }
  206. ৬। ইন্টারফেস ব্যবহার করে একটা প্রোগ্রাম ।
  207. Live Demo
  208. using System.Collections.Generic;
  209. using System.Linq;
  210. using System.Text;
  211. using System;
  212.  
  213. namespace InterfaceApplication {
  214.    
  215.    public interface ITransactions {
  216.       // interface members
  217.       void showTransaction();
  218.       double getAmount();
  219.    }
  220.    public class Transaction : ITransactions {
  221.       private string tCode;
  222.       private string date;
  223.       private double amount;
  224.      
  225.       public Transaction() {
  226.          tCode = " ";
  227.          date = " ";
  228.          amount = 0.0;
  229.       }
  230.       public Transaction(string c, string d, double a) {
  231.          tCode = c;
  232.          date = d;
  233.          amount = a;
  234.       }
  235.       public double getAmount() {
  236.          return amount;
  237.       }
  238.  public void showTransaction() {
  239.          Console.WriteLine("Transaction: {0}", tCode);
  240.          Console.WriteLine("Date: {0}", date);
  241.          Console.WriteLine("Amount: {0}", getAmount());
  242.       }
  243.    }
  244.    class Tester {
  245.      
  246.       static void Main(string[] args) {
  247.          Transaction t1 = new Transaction("001", "8/10/2012", 78900.00);
  248.          Transaction t2 = new Transaction("002", "9/10/2012", 451900.00);
  249.          
  250.          t1.showTransaction();
  251.          t2.showTransaction();
  252.          Console.ReadKey();
  253.       }
  254.    }
  255. }
  256.  
  257.  
  258.  
  259. https://drive.google.com/file/d/1JbmbBZJtSs9Q1gSQlNy8NWM4wNxHRfe0/view?usp=sharing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement