Friday, October 23, 2015
Pertemuan Kuliah Struktur Data ke 1
1. Perulangan For
#include <conio.h>
#include <iostream.h>
int main(){
for(int i=1;i<10;i++){
cout<<i;
}
getch();
)
2. Perulangan While
#include <conio.h>
#include <iostream.h>
int main(){
int i;
while (i<=10){
cout<<i;
}
getch();
}
3. Perulangan Do-while
#include <conio.h>
#include <iostream.h>
int main(){
int i;
do{
cout<<i;
i++;
}
while(i<=10)
}
getch();
}
4. Fungsi
#include <conio.h>
#include <iostream.h>
void main(){
int hitung(int a, int b){
total=0;
for(int a=1;a<=b;a++){
total=total+1;
return total;
}
getch();
}
5. Template (Fungsi)
#include <conio.h>
#include <iostream.h>
void main(){
Template<Class T>
T hitung(T a, T b){
total=0;
for(T a=1;a<=b;a++)
total=total+1;
return total;
}
getch();
}
6. Fungsi Ganjil
#include <conio.h>
#include <iostream.h>
void main(){
void ganjil(int a, int b){
for(a=1;a<=b;a++){
if(a%2!0){
cout<<a<<",";
}
getch();
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment