Posts

Showing posts from February, 2018

Write C# code to convert infix notation to postfix notation.

Image
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace InfixToPostfix {     class Program     {         static bool convert(ref string infix, out string postfix)         {             int prio = 0;             postfix = "";             Stack<Char> s1 = new Stack<char>();             for (int i = 0; i < infix.Length; i++)             {                 char ch = infix[i];                 if (ch == '+' || ch == '-' || ch == '*' || ch == '/')                 {                     if (s1.Count <= 0)                         s1.Push(ch);                     else                     {                         if (s1.Peek() == '*' || s1.Peek() == '/')                             prio = 1;                         else                             prio = 0;                         if (prio == 1)                         {                             i

Write a C# code to Perform Celsius to Fahrenheit Conversion and Fahrenheit to Celsius conversion.

Image
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace program {     class Program     {         static void Main (string[] args )         {              int celsius, faren;             Console.WriteLine("Enter Temperature in Celsius(°C) : ");             celsius = int.Parse(Console.ReadLine());             faren = (celsius * 9) / 5 + 32;             Console.WriteLine("Temperature in Fahrenheit is(°F) : " + faren);             Console.ReadLine();             double cel;             Console.Write("Enter Temperature in Fahrenheit(°F) : ");             double fahrenheit = Convert.ToDouble(Console.ReadLine());             cel = (fahrenheit - 32) * 5 / 9;             Console.WriteLine("Temperature in Celsius is(°C): " + cel);             Console.ReadLine();         }     } } Output: Enter Temperature in Celsius(°C) : 65 Temperature in Fahren

Write C# code to 1.Convert binary to decimal 2.Convert decimal to hexadecimal 3.Convert decimal to binary 4.Convert decimal to octal

Image
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Conversion {     class Program     {         static void Main(string[] args)         {             while (true)             {                 Console.WriteLine("Enter your Choice : ");                 Console.WriteLine("1. Binary to Decimal");                 Console.WriteLine("2. Decimal to Hexadecimal");                 Console.WriteLine("3. Decimal to Binary");                 Console.WriteLine("4. Decimal to octal");                 Console.WriteLine("5. All");                 Console.WriteLine("6. Exit");                 int choice = int.Parse(Console.ReadLine());                 switch (choice)                 {                     case 1:                         B2D();                         break;                     case 2:                         D2H();                         bre

Write a C# code to Convert following currency conversion.
Rupees to dollar, franc, euro.

Image
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CurrencyConversion {     class Program     {         static void Main(string[] args)         {             int choice;             Console.WriteLine("Enter your Choice :\n 1- Rupees to Dollar \n 2- Rupees to Euro \n 3- Rupees to Franc ");             choice = int.Parse(Console.ReadLine());             switch (choice)             {                 case 1:                     Double dollar, rupee, val;                     Console.WriteLine("Enter the Rupees Amount :");                     dollar = Double.Parse(Console.ReadLine());                     Console.WriteLine("Enter the Dollar Value :");                     val = double.Parse(Console.ReadLine());                     rupee = dollar / val;                     Console.WriteLine("{0} Dollar Equals {1} Rupees", rupee, dollar);                     break;                 ca

Write a C# code to convert digits to words

Image
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DigitToWord {     class Program     {         static void Main(string[] args)         {             int num;             int nextdigit;             int numdigits;             int[] n = new int[20];             string[] digits = { "zero","one","two", "three","four","five", "six","seven","eight","nine"};             Console.WriteLine("Enter the number: ");             num = Convert.ToInt32(Console.ReadLine());             Console.WriteLine("Number: " + num);             Console.Write("Number in words: ");             nextdigit = 0;             numdigits = 0;             do             {                 nextdigit = num % 10;                 n[numdigits] = nextdigit;                 numdigits++;                 num = num / 10;        

Write a program to increase and decrease font size programmatically.

Image
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication3 {     public partial class Form2 : Form     {         public Form2()         {             InitializeComponent();         }         static public Font ChangeFontSize(Font font, float fontsize)         {             if (font != null)             {                 float currentsize = font.Size;                 if (currentsize != fontsize)                 {                     font = new Font(font.Name, fontsize, font.Style, font.Unit);                 }             }             return font;         }         private void button1_Click(object sender, EventArgs e)         {             label1.Font = ChangeFontSize(label1.Font, label1.Font.Size * 2);         }         private void button2_Click(object sender, EventArgs e)         {       

Write a program to Enable-Disable Textbox and change width of TextBox programmatically in Asp.Net.

Image
Design: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>          <asp:TextBox ID="TextBox1" runat="server" Width="180px"></asp:TextBox>         <br />          <asp:Button ID="btnenable" runat="server" onclick="btnenable_Click" Text="Enable" />         <asp:Button ID="btndisable" runat="server" onclick="btndisable_Click" Text="Disable" />         <asp:Button ID="btnchange" runat="server" onclick="btndisable_Click" Text="ChangeWidth" />        </div>     </form> </body> </html> Code:- using System; using System.Collections.Generic; using System.Linq;