C SHARP – FORM – GİRİLEN SAYIYA KADAR OLAN SAYILARIN TOPLAMI


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 Girilen_Sayıya_Kadar_Olan_Sayıların_Toplamı
{
 public partial class Form1 : Form
 {
 public Form1()
 {
 InitializeComponent();
 }
 
 private void button1_Click(object sender, EventArgs e)
 {
 int sayi, toplam = 0;
 // Değişkenlerimizi belirliyoruz.
 sayi = Convert.ToInt32(textBox1.Text); 
// textbox1'e girilen sayıyı değişkene atıyoruz.
 for (int i = 0; i <= sayi; i++) 
{// Girdiğimiz sayıya kadar dönen döngü oluşturuyoruz.
 toplam += i; // Sayıları toplatıyoruz.
 textBox2.Text = toplam.ToString();
 // Sonucu textbox2'ye yazdırıyoruz.
 }
 }
 }
}
ÖNCEKİ YAYIN
Bu mevcut en yeni sayfa
SONRAKİ YAYIN
Next Post »

SAYFAMIZA ABONE OLARAK YORUMUNUZU YAPABİLİRSİNİZ Show Conversion Code Hide Conversion Code Show Emoticon Hide Emoticon

Thanks for your comment