You are on page 1of 9

Name:- Abhishek Ajay Vanjari

Enrolment No.: 2101931


Assignment

1. Write C# Program to Design following form and Display appropriate


result in message box after clicking command button.
Program:-
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 FirstWindowFrm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button2_Click(object sender, EventArgs e)


{
this.Close();
}

private void button1_Click(object sender, EventArgs e)


{
int s=int.Parse(textBox1.Text);
if(radioButton1.Checked == true)
{
int r, sum = 0, temp;
temp = s;
while(s>0)
{
r = s % 10;
sum = (sum * 10) + r;
s = s / 10;
}
if(temp==sum)
{
MessageBox.Show("Number is palindrome.");
}
else
{
MessageBox.Show("Number is not palindrome.");
}
}
if(radioButton2.Checked == true)
{
int i, m = 0, flag = 0;
m = s / 2;
if(s==0 || s==1)
{
MessageBox.Show("Number is not prime.");
}
else
{
for(i=2;i<=m;i++)
{
if(s%i==0)
{
MessageBox.Show("Number is not prime.");
flag = 1;
break;
}
}
if(flag==0)
{
MessageBox.Show("Number is prime.");
}
}
}
if(radioButton3.Checked == true)
{
int r, sum = 0, temp;
temp = s;
while(s>0)
{
r=s % 10;
sum=sum+(r*r*r);
s=s / 10;
}
if(temp ==sum)
{
MessageBox.Show("Number is Armstrong number.");
}
else
{
MessageBox.Show("Number is not Armstrong number.");
}
}
}
}
}
Screenshot:-
2. Write c#.Net Program to Design following form to store numbers in
single dimensional array and to find Maximum no & sum of all numbers
in array.
Program:-
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 WindowsFormsApp2
{
public partial class Form1 : Form
{
int[] arr = { 23, 55, 98, 44, 20 };
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
int max=arr[0];
for (int i = 1; i < arr.Length; ++i)
{
if(arr[i] > max)
{
max= arr[i];
}
}
textBox2.Text = "Maximum no. is : "+max.ToString();
}

private void textBox1_TextChanged(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
for (int i = 0; i < arr.Length; i++)
{
textBox1.Text += arr[i]+ Environment.NewLine;
}
}

private void button5_Click(object sender, EventArgs e)


{
this.Close();
}

private void button3_Click(object sender, EventArgs e)


{
int sum = 0;
for (int i = 0; i < arr.Length; ++i)
{
sum = sum + arr[i];
}
textBox3.Text = "Sum of all no. is : " + sum.ToString();
}

private void button4_Click(object sender, EventArgs e)


{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
}
}
}

Screenshot:-

3. Write C#.Net Program to Design following form to display Selected


Stream &Computer Knowledge(Use panel) and Display following
Message box. When clicked on New button form should be reset.

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

private void Form1_Load(object sender, EventArgs e)


{

private void radioButton2_CheckedChanged(object sender, EventArgs e)


{

private void button3_Click(object sender, EventArgs e)


{
this.Close();
}

private void button1_Click(object sender, EventArgs e)


{
//radio button 1
if (radioButton1.Checked == true)
{
if (checkBox1.Checked == true && checkBox2.Checked == false && checkBox3.Checked ==
false)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton1.Text + " " + groupBox2.Text + ": "+checkBox1.Text);
}
else if (checkBox1.Checked == false && checkBox2.Checked == true && checkBox3.Checked
== false)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton1.Text + " " + groupBox2.Text + ": " + checkBox2.Text);
}
else if (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked
== true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton1.Text + " " + groupBox2.Text + ": " + checkBox3.Text);
}
else if (checkBox1.Checked == true && checkBox2.Checked == true &&
checkBox3.Checked==false)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton1.Text + " " + groupBox2.Text + ": " + checkBox1.Text+", "+ checkBox2.Text);
}
else if (checkBox1.Checked == true && checkBox2.Checked == false && checkBox3.Checked
== true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton1.Text + " " + groupBox2.Text + ": " + checkBox1.Text + ", " + checkBox3.Text);
}
else if (checkBox1.Checked == false && checkBox2.Checked == true && checkBox3.Checked
== true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton1.Text + " " + groupBox2.Text + ": " + checkBox2.Text + ", " + checkBox3.Text);
}
else if (checkBox1.Checked == true && checkBox2.Checked == true && checkBox3.Checked ==
true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton1.Text + " " + groupBox2.Text + ": " + checkBox1.Text + ", " + checkBox2.Text+",
"+checkBox3.Text);
}
}
//radio button 2
if (radioButton2.Checked == true)
{
if (checkBox1.Checked == true && checkBox2.Checked == false && checkBox3.Checked ==
false)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton2.Text + " " + groupBox2.Text + ": " + checkBox1.Text);
}
else if (checkBox1.Checked == false && checkBox2.Checked == true && checkBox3.Checked
== false)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton2.Text + " " + groupBox2.Text + ": " + checkBox2.Text);
}
else if (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked
== true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton2.Text + " " + groupBox2.Text + ": " + checkBox3.Text);
}
else if (checkBox1.Checked == true && checkBox2.Checked == true && checkBox3.Checked ==
false)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton2.Text + " " + groupBox2.Text + ": " + checkBox1.Text + ", " + checkBox2.Text);
}
else if (checkBox1.Checked == true && checkBox2.Checked == false && checkBox3.Checked
== true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton2.Text + " " + groupBox2.Text + ": " + checkBox1.Text + ", " + checkBox3.Text);
}
else if (checkBox1.Checked == false && checkBox2.Checked == true && checkBox3.Checked
== true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton2.Text + " " + groupBox2.Text + ": " + checkBox2.Text + ", " + checkBox3.Text);
}
else if (checkBox1.Checked == true && checkBox2.Checked == true && checkBox3.Checked ==
true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton2.Text + " " + groupBox2.Text + ": " + checkBox1.Text + ", " + checkBox2.Text + ", " +
checkBox3.Text);
}
}
//radio button 3
if (radioButton3.Checked == true)
{
if (checkBox1.Checked == true && checkBox2.Checked == false && checkBox3.Checked ==
false)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton3.Text + " " + groupBox2.Text + ": " + checkBox1.Text);
}
else if (checkBox1.Checked == false && checkBox2.Checked == true && checkBox3.Checked
== false)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton3.Text + " " + groupBox2.Text + ": " + checkBox2.Text);
}
else if (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked
== true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton3.Text + " " + groupBox2.Text + ": " + checkBox3.Text);
}
else if (checkBox1.Checked == true && checkBox2.Checked == true && checkBox3.Checked ==
false)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton3.Text + " " + groupBox2.Text + ": " + checkBox1.Text + ", " + checkBox2.Text);
}
else if (checkBox1.Checked == true && checkBox2.Checked == false && checkBox3.Checked
== true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton3.Text + " " + groupBox2.Text + ": " + checkBox1.Text + ", " + checkBox3.Text);
}
else if (checkBox1.Checked == false && checkBox2.Checked == true && checkBox3.Checked
== true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton3.Text + " " + groupBox2.Text + ": " + checkBox2.Text + ", " + checkBox3.Text);
}
else if (checkBox1.Checked == true && checkBox2.Checked == true && checkBox3.Checked ==
true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton3.Text + " " + groupBox2.Text + ": " + checkBox1.Text + ", " + checkBox2.Text + ", " +
checkBox3.Text);
}
}
//radio button 4
if (radioButton4.Checked == true)
{
if (checkBox1.Checked == true && checkBox2.Checked == false && checkBox3.Checked ==
false)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton4.Text + " " + groupBox2.Text + ": " + checkBox1.Text);
}
else if (checkBox1.Checked == false && checkBox2.Checked == true && checkBox3.Checked
== false)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton4.Text + " " + groupBox2.Text + ": " + checkBox2.Text);
}
else if (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked
== true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton4.Text + " " + groupBox2.Text + ": " + checkBox3.Text);
}
else if (checkBox1.Checked == true && checkBox2.Checked == true && checkBox3.Checked ==
false)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton4.Text + " " + groupBox2.Text + ": " + checkBox1.Text + ", " + checkBox2.Text);
}
else if (checkBox1.Checked == true && checkBox2.Checked == false && checkBox3.Checked
== true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton4.Text + " " + groupBox2.Text + ": " + checkBox1.Text + ", " + checkBox3.Text);
}
else if (checkBox1.Checked == false && checkBox2.Checked == true && checkBox3.Checked
== true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton4.Text + " " + groupBox2.Text + ": " + checkBox2.Text + ", " + checkBox3.Text);
}
else if (checkBox1.Checked == true && checkBox2.Checked == true && checkBox3.Checked ==
true)
{
MessageBox.Show(label2.Text + ": " + textBox1.Text + " " + groupBox1.Text + ": " +
radioButton4.Text + " " + groupBox2.Text + ": " + checkBox1.Text + ", " + checkBox2.Text + ", " +
checkBox3.Text);
}
}
}

private void button2_Click(object sender, EventArgs e)


{
radioButton1.Checked = false;
radioButton2.Checked = false;
radioButton3.Checked = false;
radioButton4.Checked = false;
textBox1.Text = "";
checkBox1.Checked = false;
checkBox2.Checked = false;
checkBox3.Checked = false;
}
}
}

Screenshot:-

You might also like