Klavyeden girilen 4 haneli tamsayıyı çözümleyen C# kodu


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

namespace ConsoleApplication21
{
    class Program
    {
        static void Main(string[] args)
        {
            int sayi;
            Console.Write("Çözümlenecek Sayıyı Giriniz : ");
            sayi = int.Parse(Console.ReadLine());
            int a = (sayi / 1000);
            int b = ((sayi - (a * 1000)) / 100);
            int c = ((sayi - (a * 1000) - (b * 100)) / 10);
            int d = ((sayi - (a * 1000) - (b * 100) - (c * 10)));
            Console.WriteLine("{0} tane binlik", a);
            Console.WriteLine("{0} tane yüzlük", b);
            Console.WriteLine("{0} tane onluk", c);
            Console.WriteLine("{0} tane birlik", d);
            Console.ReadKey();
        }
    }
}

Hiç yorum yok:

Yorum Gönder