Tuesday, 28 January 2014
Sunday, 26 January 2014
C# Programs
two programs written in C#
a) sum of two numbers whether check it is palindrome or not
b) multiply of two numbers and check whether it is divisible by 5 or not
private void comboBox1_SelectedIndexChanged (object sender, EventArgs e)
{
double num1,num2;
switch (comboBox1.SelectedIndex)
{
case 0:
int n, rem,s;
num2= Convert.ToDouble(textBox1.Text ) + Convert.ToDouble(textBox2.Text );
label4.Visible = true;
n = Convert.ToInt32(num2);
s = 0;
while(n>0)
{
rem = n % 10;
s = (s * 10 )+rem; // Comment:to check whether the number is palindrome or not
n = n / 10;
}
//textBox3.Text = Convert.ToString(s);
if(num2==s)
{
textBox3.Text = "";
label4.Text = "Number is palindrome and answer cannot be displayed";
}
else
{
textBox3.Text = Convert.ToString(num2);
label4.Visible = false;
}
break;
case 1:
//to multiply two numbers whether their answers is not divisible by 5..
label4.Visible = true;
num1 = Convert.ToDouble(textBox1.Text ) * Convert.ToDouble(textBox2.Text );
if (num1 % 5 == 0)
{
textBox3.Text = "";
label4.Text = "Answer can not be Displayed";
}
else
{
textBox3.Text = Convert.ToString(num1);
label4.Visible = false;
}
break;
case 2:
textBox3.Text = Convert.ToString(Convert.ToDou ble(textBox1.Text) / Convert.ToDouble(textBox2.Text)) ;
label4.Visible = false;
break;
case 3:
textBox3.Text = Convert.ToString(Convert.ToDou ble(textBox1.Text) - Convert.ToDouble(textBox2.Text ));
break;
case 4:
textBox3.Text = Convert.ToString(Convert.ToDou ble(textBox1.Text) % Convert.ToDouble(textBox2.Text ));
break;
}
a) sum of two numbers whether check it is palindrome or not
b) multiply of two numbers and check whether it is divisible by 5 or not
private void comboBox1_SelectedIndexChanged
{
double num1,num2;
switch (comboBox1.SelectedIndex)
{
case 0:
int n, rem,s;
num2= Convert.ToDouble(textBox1.Text
label4.Visible = true;
n = Convert.ToInt32(num2);
s = 0;
while(n>0)
{
rem = n % 10;
s = (s * 10 )+rem; // Comment:to check whether the number is palindrome or not
n = n / 10;
}
//textBox3.Text = Convert.ToString(s);
if(num2==s)
{
textBox3.Text = "";
label4.Text = "Number is palindrome and answer cannot be displayed";
}
else
{
textBox3.Text = Convert.ToString(num2);
label4.Visible = false;
}
break;
case 1:
//to multiply two numbers whether their answers is not divisible by 5..
label4.Visible = true;
num1 = Convert.ToDouble(textBox1.Text
if (num1 % 5 == 0)
{
textBox3.Text = "";
label4.Text = "Answer can not be Displayed";
}
else
{
textBox3.Text = Convert.ToString(num1);
label4.Visible = false;
}
break;
case 2:
textBox3.Text = Convert.ToString(Convert.ToDou
label4.Visible = false;
break;
case 3:
textBox3.Text = Convert.ToString(Convert.ToDou
break;
case 4:
textBox3.Text = Convert.ToString(Convert.ToDou
break;
}
Code of Program in C#
case 0:
int n, rem,s;
num2= Convert.ToDouble(textBox1.Text) + Convert.ToDouble(textBox2.Text);
label4.Visible = true;
n = Convert.ToInt32(num2);
s = 0;
while (n > 0)
{
rem = n % 10;
s = (s * 10) + rem; // Comment:to check whether sum of two numbers contains zero or not
n = n / 10;
if(rem==0)
{
textBox3.Text = "";
label4.Text = "Sum of two Numbers Contains zero so answer cannot be displayed";
break;
}
else
{
textBox3.Text = Convert.ToString(num2);
}
}
break;
int n, rem,s;
num2= Convert.ToDouble(textBox1.Text) + Convert.ToDouble(textBox2.Text);
label4.Visible = true;
n = Convert.ToInt32(num2);
s = 0;
while (n > 0)
{
rem = n % 10;
s = (s * 10) + rem; // Comment:to check whether sum of two numbers contains zero or not
n = n / 10;
if(rem==0)
{
textBox3.Text = "";
label4.Text = "Sum of two Numbers Contains zero so answer cannot be displayed";
break;
}
else
{
textBox3.Text = Convert.ToString(num2);
}
}
break;
Saturday, 25 January 2014
Monday, 20 January 2014
Subscribe to:
Posts (Atom)