You are on page 1of 3

1

CURSO PROFISSIONAL TCNICO DE INFORMTICA DE GESTO

LINGUAGENS DE PROGRAMAO 11 ANO


Ficha n4 Exerccios de Reviso (Arrays)

Cdigo (C#)
using
using
using
using
using
using
using
using
using

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

namespace Exer_Revisao_04
{
public partial class Form1 : Form
{
double[] array1 = new double[10];
double[] array2 = new double[10];
double[] resultado = new double[10];
int i;
public Form1()
{
InitializeComponent();
}

Pgina 1 de 3

2013/2014

CURSO PROFISSIONAL TCNICO DE INFORMTICA DE GESTO

2013/2014

private void button7_Click(object sender, EventArgs e)


{
if (MessageBox.Show("Sair da Aplicao?", "Sair", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
{
Application.Exit();
}
}
private void button1_Click(object sender, EventArgs e)
{
//Inserir Valores Array 1
listBox1.Items.Clear();
listBox1.Items.Add("Array1");
listBox1.Items.Add("----------------------");
for (i = 0; i < 10; i++)
{
array1[i] = Convert.ToDouble(Microsoft.VisualBasic.Interaction.InputBox("Introduza a
Classificao", "Notas", "", 100, 200));
listBox1.Items.Add(array1[i]);

}
}
private void button2_Click(object sender, EventArgs e)
{
//Inserir Valores Array 2
listBox2.Items.Clear();
listBox2.Items.Add("Array2");
listBox2.Items.Add("----------------------");
for (i = 0; i < 10; i++)
{
array2[i] = Convert.ToDouble(Microsoft.VisualBasic.Interaction.InputBox("Introduza a
Classificao", "Notas", "", 100, 200));
listBox2.Items.Add(array2[i]);

}
}
private void button3_Click(object sender, EventArgs e)
{
//Somar valores
listBox3.Items.Clear();
listBox3.Items.Add("Array1 + Array2");
listBox3.Items.Add("----------------------");
for (i = 0; i < 10; i++)
{
resultado[i]=array1[i] + array2[i];
listBox3.Items.Add(array1[i] + " + " + array2[i] + " = " + resultado[i]);
}
}
private void button4_Click(object sender, EventArgs e)
{
//Subtrair valores
listBox3.Items.Clear();
listBox3.Items.Add("Array1 - Array2");

Pgina 2 de 3

CURSO PROFISSIONAL TCNICO DE INFORMTICA DE GESTO

2013/2014

listBox3.Items.Add("----------------------");
for (i = 0; i < 10; i++)
{
resultado[i] = array1[i] - array2[i];
listBox3.Items.Add(array1[i] + " - " + array2[i] + " = " + resultado[i]);
}
}
private void button5_Click(object sender, EventArgs e)
{
//Multiplicar valores
listBox3.Items.Clear();
listBox3.Items.Add("Array1 x Array2");
listBox3.Items.Add("----------------------");
for (i = 0; i < 10; i++)
{
resultado[i] = array1[i] * array2[i];
listBox3.Items.Add(array1[i] + " x " + array2[i] + " = " + resultado[i]);
}
}
private void button6_Click(object sender, EventArgs e)
{
//Dividir valores
listBox3.Items.Clear();
listBox3.Items.Add("Array1 : Array2");
listBox3.Items.Add("----------------------");
for (i = 0; i < 10; i++)
{
resultado[i] = array1[i] / array2[i];
listBox3.Items.Add(array1[i] + " : " + array2[i] + " = " + resultado[i]);
}
}
}
}

Pgina 3 de 3

You might also like