1 / 27

PROGRAM KONTROL VE DÖNGÜ DEYİMLERİ

PROGRAM KONTROL VE DÖNGÜ DEYİMLERİ. PROGRAM KONTROL VE DÖNGÜ DEYİMLERİ. PROGRAMLAR NORMALDE SATIR SATIR ÇALIŞTIRILIRLAR. İSTENİRSE BELİRLİ ŞARTLAR ARANARAK PROGRAMIN BİR KISMININ ÇALIŞTIRILMASI VEYA ÇALIŞTIRILMAMASI SAĞLANABİLİR. BUNDAN SONRAKİ DERSLERİMİZDE BU TÜR YAPILAR İLE ÇALIŞACAĞIZ.

abe
Télécharger la présentation

PROGRAM KONTROL VE DÖNGÜ DEYİMLERİ

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. PROGRAM KONTROL VE DÖNGÜ DEYİMLERİ

  2. PROGRAM KONTROL VE DÖNGÜ DEYİMLERİ • PROGRAMLAR NORMALDE SATIR SATIR ÇALIŞTIRILIRLAR. • İSTENİRSE BELİRLİ ŞARTLAR ARANARAK PROGRAMIN BİR KISMININ ÇALIŞTIRILMASI VEYA ÇALIŞTIRILMAMASI SAĞLANABİLİR. • BUNDAN SONRAKİ DERSLERİMİZDE BU TÜR YAPILAR İLE ÇALIŞACAĞIZ.

  3. IF DEYİMİ-1 • BAZI ŞARTLARIN GERÇEKLEŞTİRİLMESİ VEYA GERÇEKLEŞTİRİLMEMESİ DURUMUNDA AYRI AYRI KODLARI ÇALIŞTIRMAYA YARAR. • if şart then • komutlar..... • else • komutlar..... • end if

  4. IF DEYİMİ • dim ogrnot • ogrnot=val(text1.text) • if ogrnot>=50 then • text2.text=“geçti” • else • text2.text=“kaldı” • end if

  5. IF DEYİMİ-2 • İf şart1 then • Komutlar • Elseif şart2 then • Komutlar • Elseif şart3 then • Komutlar • Else ‘eğer hiçbir şart çalışmadıysa... • Komutlar • Endif

  6. IF DEYİMİ-2 • İf yas<5 then • print “anaokula gitmeli” • Elseif yas<12 then • prrint “ilkokula gitmali” • Elseif yas<18 then • print “liseye gitmali” • Else • Print “üniversiteye gitmali” • End if

  7. IF DEYİMİ-3 • İf şart then komutlar • ÖRNEK: • İf yas>12 then msgbox(“ilkokul bitmiş”)

  8. IF DEYİMİ-4 • İf şart then komutlar:komutlar:komutlar:komutlar • ÖRNEK: • İf a>50 then x=x+1: z=5*x

  9. SELECT CASE DEYİMİ • BİR DEĞİŞKENİN ALDIĞI BİRÇOK DEĞERE GÖRE AYRI KOMUTLARIN ÇALIŞTIRILMASI İÇİN KULLANILIR. • select case değişken • case değer1:komutlar • case değer2,değer3:komutlar • case değer4 to değer5:komutlar • case is>değer6:komutlar • case else • end select

  10. ÖRNEK • dim ogrnot • ogrnot=text1.text • select case ogrnot • case is<0, is>100:text2.text=“notunuzu yanlış girdiniz” • case 1 to 49:text2.text=“kaldı” • case 50: text2.text=“sınırda bir not aldınız” • case 51 to 70:text2.text=“iyi” • case else:text2.text=“pekiyi” • end select

  11. ÖRNEK • dim aileyard,mks • mks=3315 • select case combo1.text • case “bekar”: aileyard=0 • case “eşçalş”: aileyard=0 • case evli1ç: aileyard=int(50*mks1000)*1000 • case evli2ç: aileyard=int(100*mks)*1000 • case else • end select

  12. DÖNGÜ DEYİMLERİ • BELİRLİ BİR KOMUT GRUBUNUN BELLİ BİR ŞART GERÇEKLEŞİNCEYE KADAR DEFALARCA ÇALIŞMASINI SAĞLAR. • ÇALIŞMA SAYISININ BELLİ OLDUĞU DURUMLARDA “FOR-NEXT” DÖNGÜSÜ, DİĞER DURUMLARDA İSE “WHILE-WEND” YA DA “DO-LOOP” DÖNGÜLERİ KULLANILIR.

  13. FOR-NEXT DÖNGÜSÜ • for sayaç=başldeğeri to bitişdeğeri [step artım] • komutlar...... • next

  14. ÖRNEK • 1’DEN 20’YE KADAR OLAN SAYILARI YAZDIRAN PROGRAM • dim i • for i=1 to 20 • print i • next

  15. ÖRNEK • 1’DEN N’E KADAR OLAN SAYILARIN TOPLAMINI BULAN PROGRAM • dim i,top,n • top=0 • n=val(text1.text) • for i=1 to n • top=top+i • next • text2.text=top

  16. ÖRNEK • BİR SAYININ FAKTÖRİYELİNİ BULAN PROGRAM • dim i,sayi,fakt • fakt=1 • sayi=val(text1.text) • for i=2 to sayi • fakt=fakt*sayi • next • text2.text=fakt

  17. WHILE-WEND VE DO-WHILE DÖNGÜLERİ • BİR DÖNGÜNÜN KAÇ DEFA ÇALIŞACAĞI BİLİNMİYORSA KULLANILIRLAR. • BELİRTİLEN ŞART GERÇEKLEŞENE KADAR BELİRTİLEN KOMUT BLOKLARI ÇALIŞTIRILIR.

  18. WHILE-WEND DÖNGÜSÜ • while şart • komutlar.......... • wend

  19. ÖRNEK • while i=<5 ’burada i=<5 olduğu sürece • top=top+i ‘ i değişkeninin değeri top değişkeninine atanır. • wend ‘ i=5 ise döngüden çıkılır.değilse top=top+i işlemi devam eder.

  20. DO WHILE-LOOP • do while şart • komutlar • loop

  21. ÖRNEK • dim i,top,n • do while i<=n • i=i+1 • top=top+i • loop

  22. DO UNTIL-LOOP • DAHA ÖNCEKİ DÖNGÜLER ŞART GERÇEKLEŞTİĞİ SÜRECE ÇALIŞIYORDU. BU İSE ŞART GERÇEKLEŞENE KADAR ÇALIŞIR. • do until şart • komutlar • loop

  23. ÖRNEK • dim i,top,n • do until i=n • i=i+1 • top=top+i • loop

  24. DO-LOOP UNTIL • BU DÖNGÜDE ŞART BAŞLANGIÇTA DEĞİL SONDA KONTROL EDİLİR. BU ŞEKİLDE DÖNGÜ İÇERİSİNDEKİ KOD EN AZ 1 DEFA ÇALIŞTIRILIR. • do • komutlar • loop until şart

  25. ÖRNEK • GİRİLEN NOT 1-100 ARALIĞI DIŞINDA İSE, BU ARALIKTA NOT GİRİLENE KADAR TEKRAR TEKRAR SORULSUN. • dim nott • do • nott=inputbox(“not girişi”, “sınav notunuz”,”50”) • loop until (nott>0) and (nott<100)

  26. DO-LOOP WHILE • do • komutlar • loop while şart

More Related