### Q7 write a windows application in C# to check the number is palindrome or not and number should be entered by the user.

We know that palindrome number means if we reverse the number then it will same as entered as input. The form for this program is as follows:

Here textbox accept number and first it will be converted into integer number and assigned to the variable n. the code is as follows:

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

private void button1_Click(object sender, EventArgs e)
{
int n,rev=0,temp;

n = Convert.ToInt32(textBox1.Text);
temp = n;
while(n>0)
{
rev=rev*10+n%10;
n/=10;
}
if(temp==rev)
{
MessageBox.Show("Number is palindrome="+temp);
}
else
{
MessageBox.Show("Number is not palindrome=" + temp);
}

}
}
}

We have declared a variables n, rev=0, temp; Here we have assigned the value of n to the temp variable. Here we have used a while loop. Here we have used the condition n>0 means loop will be continued while the value of n variable is greater than 0. Inside the loop, first of all we have to calculate the remainder of the n; when we use n%10 ; this will give the last digit of the number. After that we have used the rev*10+n%10; here we add the value of remainder with rev*10 and assign to rev. now we have to get the next digit so that we have used the n/10 and assign it to n. after that we have to check that the reversed number is equal to the original number. If reverse number is same as entered number then if part will be executed otherwise else block will be executed. The output is as follows: