Question #39148

to find factorial of a number by using interface..

Expert's answer

Answer on Question#39148- Programming, C#

1. To find factorial of a number by using interface.

Solution.


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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int n = Convert.ToInt32(textBox1.Text); // number of cycles Factorial
            int factorial = 1; // factorial value
            // The cycle starts with 2, because it makes no sense to start with 1
            for (int i = 2; i <= n; i++)
            { factorial = factorial * i; }
            textBox2.Text = factorial.ToString();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS