C#.NET Program 16

Output:





















Code:

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 Question_6
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        //Create factorial() function
        public void factorial()
        {
            long fact = 1;
            for (int i = 1; i <= long.Parse(textBox1.Text); i++)
            {
                fact = fact * i;
            }
            MessageBox.Show("Factorial of Your Number Is: " + fact);
        }

        //factorial button
        private void button1_Click(object sender, EventArgs e)
        {
            factorial();
        }

        //create odd_even() function
        public void Odd_Even()
        {
            if (int.Parse(textBox1.Text) % 2 == 0)
            {
                MessageBox.Show("Number Is Even");
            }
            else
            {
                MessageBox.Show("Number Is Odd ");
            }
        }

        //odd_even button
        private void button2_Click(object sender, EventArgs e)
        {
            Odd_Even();
        }

       
    }
}




No comments:

Post a Comment