for(int i=0;i<10;i++){
file.WriteLine(a + i*d);
}
file.Close();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
3-topshiriq.
Formaga 3 ta TextBox va bitta Button elementlarini joylang.textBox1 va textBox2 ga ixtiyoriy haqiqiy sonlar kiritilib ,Button1 tugmasi bosilganda textBox3 ga kiritilgan haqiqiy sonlarning kvadratlari yig’indisi agar haqiqiy sonlardan birortasi xato kiritilsa “Son xató kiritildi ”yozuvi chiqadigan dastur tuzing.
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace topshiriq_3
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
label1.Text="1-son";
label2.Text="2-son";
label3.Text="natija";
button1.Width=150;
button1.Height=30;
button1.Text="natijani olish uchun bosing";
}
void Button1Click(object sender, EventArgs e)
{
try{
double x=Convert.ToDouble(textBox1.Text);
double y=Convert.ToDouble(textBox2.Text);
textBox3.Text=Convert.ToString(x*x+y*y);}
catch
{
textBox3.Text="Sonni xato kiritdingiz";
}
}
}
}
Do'stlaringiz bilan baham: |