1 / 13

Öğr .Gör.Mustafa YAVAŞ

Rize MYO Bilgisayar Teknolojileri. Hafta-2 C# - Console application uygulama çalIşmalarI. Öğr .Gör.Mustafa YAVAŞ. www. mustafayavas .org. void aMethod() { float f = (1 / 4) * 10; int i = Math.round(f); Console.WriteLine(i); }

mea
Download Presentation

Öğr .Gör.Mustafa YAVAŞ

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Rize MYO Bilgisayar Teknolojileri Hafta-2 C# - Consoleapplication uygulama çalIşmalarI Öğr.Gör.Mustafa YAVAŞ www.mustafayavas.org

  2. void aMethod() { float f = (1 / 4) * 10; int i = Math.round(f); Console.WriteLine(i); } Derlenince hata verir donusum yapmadan float degişkeni int degişkene atama yapıyor..calışması icin double i olmalı.

  3. int i=1, j=10; do { Console.Write(++i + “,”); } while (i<j); Console.WriteLine(i); Sonuc : 2,3,4,5,6,7,8,9,10,10 eger ++i ise Sonuc : 2,3,4,5,6,7,8,9,10 eger i++ ise

  4. for (int m=10; m>=1; m/=2) Console.Write(m + “,”); Sonuc int m =10,5,2,1, Float olsa : 10,5,2.5,1.25,

  5. int i = 6; Console.Write (i++); 6 yazar ve arttırırak sonraki satıra gecer Console.Write (++i); 7 dir ve arttırarak burayı 8 yapar Console.Write (i); burayada 8 yazar 6 8 8

  6. double pi = 3.1; double yaricap; double cevre = 2.0 * pi * yaricap; Cevap : Ekranda Console.WriteLine() yok o yuzden ekran boş gelir. --------------------------

  7. double pi = 3.1; int n = 2; n = n * pi; Console.WriteLine(n); Veri tipi uyuşmazlıgından pi double ve n ise int, N=n* (int) pi; düzelir. Yada n double olarak tanımlanırsa sonuc 6 cıkar.

  8. int a = 4; while (a >= 0.5) { Console.Write(a); a = a / 2; } Sonuc : 421

  9. bool b1 = true, b2 = false; int i1 = 1, i2 = 3; double f1 = 3.5, f2 = 0; if ( (i2 > 2) || ( f1 < 10) ) if (!b1) i1 = (int) f1; else i1 = (int) f2; else i2 = (int) (f1 + 2.0); Console.WriteLine(b1 + ", " + b2 + ", " + i1 + ", " + i2 + ", " + f1 + ", " + f2); Sonuc : true, false, 0, 3, 3.5, 0

More Related