0

1- Girilen sayının kaç basamaklı oldugunu gösteren programı c# diliyle yazınız.

2-ax2 + bx + c = 0tipindeki bir denklemin köklerini bulan programı c# diliyle yazınız.

3- Girilen bir kelimenin keyASCII kodlarının toplamını veren programı c# diliyle yazınız.

4- Girilen n basamaklı sayının birler,onlar,yüzler… basamaklarını bulan programı c# diliyle yazınız.

5- Girilen n basamaklı bir sayının basamaklarının küpleri toplamı sayının kendine eşit olup olmadıgını bulan programı c# diliyle yazınız.

6- Girilen sayının mükemmel sayı olup olmadıgını bulan programı c# diliyle yazınız. (28 mükemmel sayıdır.)

Cevaplar

1-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
double t;
            a = Convert.ToInt32(Console.ReadLine());
            Console.Clear();
for (int i = 1; i <= a; i++)
            {
                t = a / Math.Pow(10, i);
                if (t >= 1 & t <= 9)
                {
                    Console.WriteLine("Girilen  {0} sayısı {1}basamaklıdır",Convert.ToString(a),Convert.ToString(i+1));
                    break;
                }
            } 
           
            Console.ReadKey();
        }
    }
}

2-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
double delta;
                
                 Console.WriteLine("ax2+bx+c=0 biçimindeki denklemin katsayılarını giriniz...");
Console.Write("a = ");
            a=Convert.ToInt32(Console.ReadLine());
                Console.Write("b = ");
            b=Convert.ToInt32(Console.ReadLine());
                Console.Write("c = ");
            c = Convert.ToInt32(Console.ReadLine());
            delta=Math.Pow(b,2)-4*a*c;
            Console.Clear();
Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("{0}x2+{1}x+{2}=0 denkleminin kökleri",a,b,c);
            if (delta<0) {
                Console.WriteLine("REEL KÖK YOKTUR...");
                }
                else if (delta==0){
            Console.WriteLine("Denklemin çakışık iki kökü vardır x_1_2= {0}",-b/2*a);
            }
            else if (delta > 0) {                Console.WriteLine("x_1={0} ", (-b + Math.Sqrt(delta))/2*a);
                Console.WriteLine("x_2={0} ", (-b - Math.Sqrt(delta)) / 2 * a);
            }
            Console.ReadKey();
        }
    }
}

3-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            int toplam =0;
string a = Console.ReadLine();
            int b = a.Length;
for (int i = 0; i <b;i++ ){
               // Console.WriteLine(a[i]);
                int t = (int)a[i];
                toplam = toplam + t;
            }
            Console.Clear();
Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(a + "  kelimesinin keyASCII kodları toplamı " + Convert.ToString(toplam)+"  dir.");
            Console.ReadKey();
        }
    }
}

4-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            int b = a.Length;
for (int i = b-1; i >= 0; i--)
            {
                Console.Write(a[i]);
if (i == b - 1)
                {
                    Console.WriteLine("     Birler basamağı");
                }
                else if (i == b - 2)
                {
                    Console.WriteLine("     Onlar basamağı");
                }
                else if (i == b - 3)
                {
                    Console.WriteLine("     Yüzler basamağı");
                }
                else if (i==b-4)
                    Console.WriteLine("     Binler basamağı");                else if (i==b-5)
                    Console.WriteLine("     On binler basamağı");
                else if (i==b-6)
                    Console.WriteLine("     Yüz binler basamağı");
                else if (i==b-7)
                    Console.WriteLine("     Milyonlar basamağı");
                else if (i==b-8)
                    Console.WriteLine("     On milyonlar basamağı basamağı");
                else if (i==b-9)
                    Console.WriteLine("     Yüz milyonlar basamağı");
                }            
            Console.ReadKey();
        }
    }
}

5-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
string a = Console.ReadLine();
            int b = a.Length;
int y = Convert.ToInt32(a);
            int c = 0;
for (int i = 0; i <= b - 1; i++) {
                c = c + int.Parse(a.ToString().Substring(i, 1)) * int.Parse(a.ToString().Substring(i, 1)) *
int.Parse(a.ToString().Substring(i, 1));
                
            }
            Console.Clear();
Console.WriteLine("sayının basamak değerlerinin küpleri toplamı={0}", c);
                if (c==y)
                {
                    Console.BackgroundColor=ConsoleColor.Gray;
                    Console.WriteLine("sayının basamak değerlerinin küpleri toplamı sayının kendisine eşittir");
                }
                else
                    Console.BackgroundColor=ConsoleColor.Green;
                Console.WriteLine("sayının basamak değerlerinin küpleri toplamı sayının kendisine eşit değildir.");
            Console.ReadKey();
        }
    }
}

6-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication12
{
    class Program
    {
        static void Main(string[] args)
        {
            int toplam = 0;
int a = Convert.ToInt32( Console.ReadLine());
            for (int i = 1; i <a; i++) {
                if (a % i == 0) {                    toplam = toplam + i;
                }
            }
            Console.Clear();
Console.WriteLine(Convert.ToString(toplam));
            if (a==toplam)
Console.WriteLine("Girilen {0} sayısı mükemmel sayıdır", Convert.ToString(a));
            else
Console.WriteLine("Girilen {0} sayısı mükemmel sayı değildir", Convert.ToString(a));
            Console.ReadKey();
        }
    }
}
Bu İçeriğe Tepkin Ne Oldu?
  • 2
    ba_ar_l_
    Başarılı
  • 0
    gayet_yi
    Gayet İyi
  • 0
    te_ekk_rler
    Teşekkürler
  • 0
    anlamad_m
    Anlamadım
  • 0
    yetersiz
    Yetersiz
Subscribe
Bildir
guest

Bu site, istenmeyenleri azaltmak için Akismet kullanıyor. Yorum verilerinizin nasıl işlendiği hakkında daha fazla bilgi edinin.

0 Yorum
Inline Feedbacks
View all comments