Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

PROSES PERULANGAN.

Presentasi serupa


Presentasi berjudul: "PROSES PERULANGAN."— Transcript presentasi:

1 PROSES PERULANGAN

2 PROSES PERULANGAN Pernyataan For - Nested For
- Perulangan Tak Berhingga Pernyataan Goto Pernyataan While Pernyataan Do –While Pernyataan Break Pernyataan Continue

3 Pernyataan For #include<conio.h> #include<iostream.h>
Contoh 2 For : #include<conio.h> #include<iostream.h> main() { int a; clrscr(); for(a=10; a >= 1; --a) cout<<a; getch(); } Contoh 1 For : #include<conio.h> #include<iostream.h> main() { int a; clrscr(); for(a=1; a <= 10; ++a) cout<<a; getch(); } Inisialisasi : bag. Unk memberi nilai awal Syarat : mengontrol perulangan. Mau diteruskan berulang atau dihentikan Pengubah nil. Pencacah : mengatur kenaikan / penurunan nilai

4 Pernyataan Nested For Hasil Run : #include<conio.h>
Contoh 1 Nested For : #include<conio.h> #include<stdio.h> main() { int a,b; clrscr(); for(a=5;a>=1;a-=1) printf("\n"); for(b=a;b>=1;b-=1) printf("%d",a-b+1); } getch(); Hasil Run : Soal Hasil Run :

5 Pernyataan Tak Berhingga
Contoh : Hasil Run :

6 Pernyataan Goto Bentuk Umum #include<stdio.h>
#include<conio.h> #include<iostream.h> main() { int a,b; char lagi; atas: clrscr(); cout<<"Masukan Bilangan = ";cin>>a; b=a%2; printf("Nilai %d %% 2 adalah =%d",a,b); printf("\n\n Ingin Hitung Lagi [Y/T]:"); lagi=getche(); if(lagi=='Y'||lagi=='y') goto atas; getch(); }

7 Pernyataan While #include<conio.h> #include<iostream.h>
main() { int i; clrscr(); i =0; while (i<10) cout<<"C++"<<endl; i++; } getch();

8 Pernyataan Do - While #include<stdio.h> #include<conio.h>
#include<iostream.h> main() { int bil=2; clrscr(); do { printf("%d",bil); bil+=2; } while(bil<=10); getch();

9 Pernyataan Break #include<stdio.h> #include<conio.h>
main( ) { int bil=1; clrscr( ); do if (bil>=6) break; printf("%d",bil); } while(bil++); getch( );

10 Pernyataan Continue #include<stdio.h> #include<conio.h>
main() { int bil; clrscr(); for(bil=1;bil<=10;++bil) if(bil==6) continue; printf("%d",bil); } getch();


Download ppt "PROSES PERULANGAN."

Presentasi serupa


Iklan oleh Google