ANALISIS Input : jumlah detik
Output : jam,menit,detik
NOTASI DEKLARASI
integer j,m,d,dm,sisa,sisa1
DESKRIPSI
Input : dm(jumlah detik)
if (dm/3600)>0
j=dm / 3600;
sisa=dm-(j*3600)
else
j=0
sisa=dm
if ((sisa/60)>0)
m=sisa / 60
sisa1=sisa-(m*60)
else
m=0
sisa1=sisa
LISTING/SOURCE CODE
#include “stdio.h”#include “conio.h”void main(){int j,m,d,dm,sisa,sisa1;printf(“program mengkonfersi waktu\n”);printf(“=============================\n”);printf(“\n”);printf(“masukan jumlah detik : “);scanf(“%i”,&dm);printf(“\n”);printf(“=============================\n”);if ((dm/3600)>0){j=dm / 3600;sisa=dm-(j*3600);}else{j=0;sisa=dm;}if ((sisa/60)>0){m=sisa / 60;sisa1=sisa-(m*60);}else{m=0;sisa1=sisa;}d=sisa1;printf(“hasil=>> %i jam %i menit %i detik”,j,m,d);getch();}
ANALISIS
Input : banyaknya bilangan,angka bilangan
Output : total,rata rata
NOTASI
DEKLARASI
integer n,i,u,x[100]
float rata,tot
DESKRIPSI
Input : banyaknya bilangan,angka bilangan
for (u=1;u<=n;u++)
x[u]
tot=tot+x[u]
LISTING/SOURCE CODE
#include "stdio.h"#include "conio.h"void main(){int n,i,u;float rata,tot;int x[100];tot=0;printf("program menghitung rata-rata\n");printf("=============================\n");printf("\n");printf("masukan jumlah bilangan : ");scanf("%i",&n);printf("\n");for (u=1;u<=n;u++){printf("masukan bilangan ke-%i : ",u);scanf("%i",&x[u]);tot=tot+x[u];}printf("=============================\n");printf("total : %7.2f\n",tot);rata=tot/n;printf("rata-rata : %7.2f",rata);getch();}
ANALISIS
Input : bilangan ganjil kurang dari 19
Output : *
NOTASI
DEKLARASI
integer gajil,i,j,z
LISTING/SOURCE CODE
#include "conio.h"#include "stdio.h"#include "iostream.h"int main(){int ganjil;do{printf(“Masukkan bilangan ganjil (1-19): “);scanf(“%i”,&ganjil);} while(ganjil%2==0);for(int i=0; i<=ganjil; i+=2){for(int j=0; j<ganjil-i;j+=2){printf(" ");}for(int z=0;z<=i;z++){printf("*");}cout<<endl;}ganjil = ganjil – 2;for(int i=0; i<ganjil; i+=2){for(int j=0; j<=i+2;j+=2){printf(" ");}for(int z=1;z<=ganjil-i;z++){printf("*");}cout<<endl;}getch();return 0;}
ANALISIS
Input : bilangan yang dicari
Output : bilangan yang dicari terletak pada array… deret ke-….
NOTASI
DEKLARASI
const integer ukuran=10
integer array[ukuran]={25,36,2,48,0,69,14,22,7,19}
integer cari
LISTING/SOURCE CODE
#include "conio.h"#include “iostream.h”int cari(int array[],int ukuran, int cari);void main(){const int ukuran=10;int array[ukuran]={25,36,2,48,0,69,14,22,7,19};cout<<"Isi dari array: "<<endl;for(int i=0;i<ukuran;i++)cout<<" "<<array[i];int cari;int tanda=-1;cout<>cari;tanda= cari(array,ukuran,cari);if (tanda!=-1)cout<<"\n\nData tersebut ditemukan pada posisi:array["<<tanda<<"],"<<" atau deret ke-"<<(tanda+1);elsecout<<"\nData tersebut tidak ditemukan ";getch();}int cari(int array[],int ukuran,int cari){int tanda=-1;for(int i=0;i<ukuran;i++){if(cari==array[i]){tanda=i; break;}return tanda;}
ANALISIS
Input : banyaknya data, nilai tiap data(acak)
Output : nilai semua data(terurut)
NOTASI
DEKLARASI
int a
int up,down
int temp
int arr[max]
int i,n,lb,ub
quick_sort(int darr[max], int lb, int ub)
LISTING/SOURCE CODE
#include "conio.h"#include “iostream.h”#define max 20void quick_sort(int darr[max], int lb, int ub){int a;int up,down;int temp;if (lb>=ub)return;a=darr[lb];up=ub;down=lb;while (down < up){while (darr[down] a)up–;if(down<up){temp=darr[down];darr[down]=darr[up];darr[up]=temp;}}darr[lb]=darr[up];darr[up]=a;quick_sort(darr,lb,up-1);quick_sort(darr,up+1,ub);}void main(){int arr[max];int i,n,lb,ub;lb=0;cout<>n;ub=n;cout<<"Masukkan data-datanya: \n\n";for(i=1;i<=n;i++){cout<<"\tdata ke- "<<i<>arr[i];}quick_sort(arr,lb,ub);cout<<"\nHasil pengurutan data: ";for(i=0; i<n;i++)cout<<" "<<arr[i];cout<<"\n\nTekan sembarang tombol untuk keluar ";getch();}
Komentar
Posting Komentar
Komen ya :D