using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ch4_5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label2.Text = "Result : ";
            int num = Convert.ToInt32(textBox1.Text);
            int digit, mag = 0, sumOfDigit = 0;
            string str ="";
            // Compute number of digits
            while (num > 0)
            {
                mag++;
                num = num / 10;
            }
            //Compute inverse
            num = Convert .ToInt32 (textBox1 .Text);
            do
            {
                digit = num % 10;
                sumOfDigit += digit;
                str += digit.ToString();
                num /= 10;
            } while (num != 0);
            label2.Text += "\n" + "Number = " + textBox1.Text + "\n" +
                "Number of digits = " + mag.ToString() + "\n" +
                "Sum of digits = " + sumOfDigit.ToString() + "\n" +
                "Inverse of number is : " + str;
        }
    }
}
