Tips for heathy life

Tips for heathy life

Minggu, 02 November 2008

Dispay array in C++ programme

I want to share program that display array in C++. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

#include <>
#include <>
#include <>

void main ( )
{
clrscr( );
int nilai[6] = {4,2,3,5,1,6};
int i;

for(i=1;i<6 i=""><<"="; cout <<:i endl="">

How to display 10 integer and summation of that integer in C++?


I want to share how to display 10 integer and summation. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

---------------------
#include
#include
void main ( )
{
clrscr( );
int i,x,jml;
int index[10] = {1,2,3,4,5,6,7,8,9,10};
for(i=1;i<11 br="" i=""> {
cout<<"Input integer number- "< cin< jml=x;
jml=jml+x;
cout<<"Total of integer = "< }
getch( );
}

How make program that calculates flat wake in C++?

I want to share program that calculate flat wake in C++. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

--------
#include
#include

void main ( )
{
const float phi=3.14;
float r,a,t,kell,luas;
int kode;
char pilih;

awal :
cout<<"||======================================||"<<<"||Program menghitung rumus bangun datar ||"<<<"||======================================||"<<<"\n 1. Keliling Lingkaran "<<<"2. Luas Segitiga "<<<"\n Pilihan anda adalah (1..2) = "; cin>>kode;
switch (kode)
{
case 1 :
cout<<"Anda memilih nomor 1 yaitu menghitung keliling lingkaran"; cout<<"\nMasukkan jari-jari = "; cin>>r;
kell=2*phi*r;
cout<<"\nKeliling Lingkaran = "<<<<"Anda memilih nomor 2 yaitu menghitung luas segitiga"; cout<<"\nMasukkan alas = "; cin>>a;
cout<<\nMasukkan tinggi = "; cin>>t;
luas=a*t*0.5;
cout<<"\nLuas Segitiga = "<<<<"\nMaaf anda memasukkan kode yang salah"<<<"Ingin mengulang lagi [Y/T] = "; cin>>pilih;
if ((pilih=='Y'||(pilih=='y'))
{
goto awal;
}
clrscr ( );
cout<<"\nGoodbye!!!";
}
goto awal;
getch ( );
}

How make display date in pascal?


I want to share program that display date in Pascal. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

Date Programme (input,output);

uses wincrt;
const
teks='Input date on mm dd yy(0 0 0 to stop)';
typestring=string[20];
arraytipestring=array[1..12] of tipestring;
var
month,day,year:integer;
outputdate:tipestring;
namemonth:arraytipestring;
Procedure displaynamemonth(var namemonth:arraytipestring);

begin
namemonth[1] :='Januari';
namemonth[2] :='Februari';
namemonth[3] :='Maret';
namemonth[4] :='April';
namemonth[5] :='Mei';
namemonth[6] :='Juni';
namemonth[7] :='Juli';
namemonth[8] :='Agustus';
namemonth[9] :='September';
namemonth[10] :='Oktober';
namemonth[11] :='November';
namemonth[12] :='Desember';
end;

Function DateConvert(M,D,Y:integer):

typestring;

var
day,year:tipestring;

begin
str(D,Day);
str(Y:2,year);
if year[1]:=' ' then year[1]:='0';
year:='19' + year;
if (m>=1) and (m<=12) then
DateConvert:=namemonth[M] + day + ' ' + year
else
DateConvert:='Wrong Date';
end;

Begin
displaynamemonth(namemonth);
write(teks);
readln(month,day,year);
while month and day <> 0 do
begin
resultdate:= DateConvert (month,day,year);
writeln('date numeric = ',month:3,day:3,year:3);
writeln('alpha numeric = ',hasildate);
write(teks);
readln(month,day,year);
end.

BUBLE ASCENDING in Pascal

Program Buble_Ascending_09;

uses wincrt;

var
i,k, temp:integer;
L:array[1..5] of integer;
flag:boolean;

begin
clrscr;
L[1]:=1;
L[2]:=50;
L[3]:=10;
L[4]:=3;
L[5]:=2;

flag:=false;
i:=1;
while (i<5 and="" br="" do="" flag="" not=""> begin
flag:=true;
for k:=5 downto 1 do
if(L[k] begin
temp:=L[k];
L[k]:=L[k-1];
L[k-1]:=temp;
flag:=false;
end;
inc(i);
end;

begin
for i:=1 to 5 do
writeln(L[i],' ');
writeln;
end;

end.

STACK in Pascal

Program ArrayStack;

uses wincrt;

const
max=10;

var
Top,i:byte;
Pil,temp,e:char;
Stack:array [1..max] of char;

Procedure PushAnim;

begin
for i:=1 to 18 do
begin
gotoxy(23+i,7);write(temp);{delay(30); }
gotoxy(23,7);clrEol;
end;

for i:=1 to 14-top do
begin
{delay(30); }
gotoxy(41,6+i);write(' ');
gotoxy(41,7+i);write(temp);
end;
end;

Procedure PopAnim(temp:char);

begin
for i:=1 to 14-top do
begin
{delay(30); }
gotoxy(41,22-i-top);write(temp);{delay(30); }
gotoxy(41,21-i-top);ClrEol;
end;
end;

Procedure Push(e:char);

begin
inc(top);
Stack[top]:=e;
PushAnim;
end;

Procedure Pop(e:char);

begin
if top <> 0 then
begin
e:=stack[top];PopAnim(e);
dec(top);
end else
begin
gotoxy(1,7);write(' Stack Telah Kosong ');readkey;
gotoxy(1,7);ClrEol;
end;
end.

begin
clrscr;
writeln(' ANIMASI STACK ');
writeln(' 1. Push ');
writeln(' 2. Pop ');
writeln(' 3. Quit ');
writeln(' Pilihan [1/2/3] = ');
gotoxy(59,6);write(' \ ');
gotoxy(59,8);write(' / ');
gotoxy(37,10);write(' \ /');
for i:= 1 to 11 do
begin
gotoxy(38,10+i);
if i= 11 then write(' |_______________________________| ') else
write(' |........................| ');
end;
top:=0;
repeat
gotoxy(19,5);ClrEol;
Pil:=readkey;write(Pil);
if Pil='1' then
begin
if top <> max then
begin
gotoxy(1,7);write('Masukkan suatu huruf = ');
temp:=readkey;write(temp);
Push(temp);
gotoxy(1,7);CLrEol;
end else
begin
gotoxy(1,7);write(' Stack telah penuh' );
readkey;
gotoxy(1,7);ClrEol;
end;
end else
if Pil='2' then Pop(temp);
until Pil='13';
end.

ARRAY in Pascal

uses wincrt;

var
data:array[1..7,1..7] of byte;
baris,kolom:integer;

begin

for baris:=1 to 7 do
begin
for kolom:=1 to 7 do
if (baris=kolom) or (baris+kolom=8) or (baris=4) or (kolom=4) then

data[baris,kolom]:=0
else
data[baris,kolom]:=1;
end;

for baris:=1 to 7 do
begin
for kolom:=1 to 7 do
write(' ',data[baris,kolom]);
writeln;
end;
end;