SlideShare a Scribd company logo
1 of 8
PERULANGAN (LOOPING)
Looping merupakan proses perulangan suatu
blok pernyataan sebanyak yang diinginkan.
Ada tiga bentuk dalam proses perulangan:
1. Perulangan While
2. Perulangan Do..While
3. Perulangan For
1. Perulangan While
Perulangan ini digunakan jika jumlah perulangannya belum
diketahui. Proses perulangan akan terus berlanjut selama
kondisinya bernilai benar (true) dan akan berhenti bila
kondisinya bernilai salah.
Bentuk Umum :
While (kondisi)
{
Statement
. . .
}
 Contoh program while
#include<stdio.h>
#include<conio.h>
main()
{
int i=0,jum=0;
clrscr();
while (i<=10)
{
i++;
printf("%4dn",i);
jum=jum+i;
}
printf("-----+n");
printf("%4d",jum);
getch();
}
2.Perulangan Do..while
Pada dasarnya struktur perulanagn ini sama saja dengan struktur
While, hanya saja pada proses perulangan dengan while, seleksi
berada di while yang letaknya diatas, sementara pada perulangan
do … while, seleksi berada dibawah batas perulangan. Jadi dengan
menggunakan struktur do .. while sekurang – kurangnya akan terjadi
satu kali perulangan.
Bentuk Umum :
Do
{
Statement
. . .
}
While (kondisi)
Contoh program Do…While
#include<stdio.h>
#include<conio.h>
main()
{
int i;
clrscr();
i=1;
do
{
printf("%dn",i);
i++;
}
while(i<=5);
}
3. Perulangan for
 Struktur perulangan for biasa digunakan unutk mengulang suatu
proses yang telah diketahui jumlah perulangannya.
 Bentuk Umum :
Keterangan :
 Inisialisasi
Pernyataan untuk menyatakan keadaan awal dari variable control.
 Syarat
Ekspresi relasi yang menyatakan kondisi unutk keluar dari
perulangan.
 Penambahan
Pengatur perubahan nilai variable control.
For (inisialisasi; syarat; penambahan)
{
Statement
. . .
}
Contoh program for
#include<stdio.h> Tampilan program
#include<conio.h>
main()
{
int i;
for (i=10;i>0;i--)
{
printf("n Bahasa C%5i",i) ;
}
getch();
}
Contoh For bersarang
#include<stdio.h>
#include<conio.h>
main()
{
int i,n,j;
for (i=1; i<=3; i++)
{
for (j = 1; j <=i ; j++)
{
printf(“*”);
}
Printf(“n”);
}
Printf("program selesai");
}

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

PERULANGAN (LOOPING) PADA PEMROGRAMAN KOMPUTER

  • 1. PERULANGAN (LOOPING) Looping merupakan proses perulangan suatu blok pernyataan sebanyak yang diinginkan. Ada tiga bentuk dalam proses perulangan: 1. Perulangan While 2. Perulangan Do..While 3. Perulangan For
  • 2. 1. Perulangan While Perulangan ini digunakan jika jumlah perulangannya belum diketahui. Proses perulangan akan terus berlanjut selama kondisinya bernilai benar (true) dan akan berhenti bila kondisinya bernilai salah. Bentuk Umum : While (kondisi) { Statement . . . }
  • 3.  Contoh program while #include<stdio.h> #include<conio.h> main() { int i=0,jum=0; clrscr(); while (i<=10) { i++; printf("%4dn",i); jum=jum+i; } printf("-----+n"); printf("%4d",jum); getch(); }
  • 4. 2.Perulangan Do..while Pada dasarnya struktur perulanagn ini sama saja dengan struktur While, hanya saja pada proses perulangan dengan while, seleksi berada di while yang letaknya diatas, sementara pada perulangan do … while, seleksi berada dibawah batas perulangan. Jadi dengan menggunakan struktur do .. while sekurang – kurangnya akan terjadi satu kali perulangan. Bentuk Umum : Do { Statement . . . } While (kondisi)
  • 5. Contoh program Do…While #include<stdio.h> #include<conio.h> main() { int i; clrscr(); i=1; do { printf("%dn",i); i++; } while(i<=5); }
  • 6. 3. Perulangan for  Struktur perulangan for biasa digunakan unutk mengulang suatu proses yang telah diketahui jumlah perulangannya.  Bentuk Umum : Keterangan :  Inisialisasi Pernyataan untuk menyatakan keadaan awal dari variable control.  Syarat Ekspresi relasi yang menyatakan kondisi unutk keluar dari perulangan.  Penambahan Pengatur perubahan nilai variable control. For (inisialisasi; syarat; penambahan) { Statement . . . }
  • 7. Contoh program for #include<stdio.h> Tampilan program #include<conio.h> main() { int i; for (i=10;i>0;i--) { printf("n Bahasa C%5i",i) ; } getch(); }
  • 8. Contoh For bersarang #include<stdio.h> #include<conio.h> main() { int i,n,j; for (i=1; i<=3; i++) { for (j = 1; j <=i ; j++) { printf(“*”); } Printf(“n”); } Printf("program selesai"); }