Langsung ke konten utama

5 program sederhana mengunakan c++


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);
else
cout<<"\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 20
void 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

Postingan populer dari blog ini

Android Shared 3 : Memulai Belajar XML Untuk Membuat Layout

Assalamu'alaikum wr wb Pagi-pagi semangat ngeblog lagi menggebu-gebu , padahal semalem sempet agak panas dingin nie badan, dengan ditemani secangkir saya akan meneruskan post Android shared berikutnya. Eh lagi asik-asiknya si ayang tlp , jadi kepending deh nge-blognya sampak siang . Anyway langsung aja lah dari pada jadi bahan gosipan . Melanjutkan Shared 2 , disini saya akan membahas tentang XML untuk membuat tampilan dari aplikasi andorid . Sebagai salah satu OOP , android juga memiliki objek-objek seperti kebanyakan OOP . Sebagai contoh, ini objek yang ada di p allete form widget di eclipse . Dari banyaknya objek-objek di atas, yang umum sering di gunakan yaitu : TextView digunakan untuk membuat label / tulisan Button digunakan sebagai tombol untuk mengeksekusi perintah CheckBox digunakan untuk suatu pilihan/lebih dari 1 option, yang mana pilihan tersebut bisa dipilih lebih dari 1 atau dipilih semua pada 1 Question. RadioButton hampir mirip dengan

Storyboard

What is the Story board? Storyboard is a column of text, audio and visualization with information about the content and visuals that are used for the production of a course. Storyboard can be different degrees as there are various stages that must be passed to the purpose of making the story board. Storyboard is a concept of communication and creative expression, techniques and media to convey messages and ideas visually, including audio by processing a form of graphic design elements and images, fonts and colors, and layout, so the message and ideas can be accepted by the target. Storyboard is also not limited to making the ad only because the production of games, multimedia cd and elearningpun using story board. What should be considered in writing the storyboard?

EASY MONEY | STAR-CLICKS PTC

Star-Clicks is a PTC (paid-to-click) site managed by Easy Logic. It has been operating since 2008. They partner with companies or individuals who want to increase their site’s online traffic. This site allows you to earn cash by viewing ads for a small reward which is USD 0.01 per ad. Once you become a member, you can start earning simply by viewing ads. The good thing about this site is there are no pop-up ads nor solving captchas. All you need to do is to click an ad and wait for it to load in a new tab. When it is done, your earnings will be credited to your account immediately. It is pretty simple. Unlike other PTC sites, Star-Clicks main earning is viewing ads. Other PTC sites do surveys, games, and more. You can also earn through their ( referral ) system as all PTC sites do. You share your referral link and once someone signs-up under your link, you earn a certain amount. Star-Clicks uses 3 payment methods. PayPal, direct bank and you may also convert your earnings to Bitco