C# ta Klavyeden Girilen 10 Tane Sayının Tek Olanların Ve Çift Olanların Toplamı

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication38
{
    class Program
    {
        static void Main(string[] args)
        {
            int x,cift=0,tek=0 ;
            for (int i = 1; i <=10; i++)
            {
                Console.Write("sayı girin :");
                x = Convert.ToInt32(Console.ReadLine());
                if (x%2==0)
                {
                    cift += x;
                }
                else if (x%2==1)
                {
                    tek += x;
                }
                
            }
            Console.WriteLine("girdiğin çift sayıların toplamı ={0}",cift);
            Console.WriteLine("girdiğin tek sayıların toplamı ={0}", tek);
        }
    }
}

Yorum Gönder

0 Yorumlar