0% found this document useful (0 votes)
106 views

Program Menghitung Luas Persegi Panjang

The document contains 3 code programs: 1. A program to calculate the area of a rectangle by inputting length and width and outputting the area. 2. A program to calculate the area of a triangle by inputting base and height and outputting the area. 3. An animation program that animates the characters "C++" by using procedures and coordinates to print "*" characters with delays, representing each character.

Uploaded by

irpan ramdani
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views

Program Menghitung Luas Persegi Panjang

The document contains 3 code programs: 1. A program to calculate the area of a rectangle by inputting length and width and outputting the area. 2. A program to calculate the area of a triangle by inputting base and height and outputting the area. 3. An animation program that animates the characters "C++" by using procedures and coordinates to print "*" characters with delays, representing each character.

Uploaded by

irpan ramdani
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Program Menghitung Luas Persegi panjang

#include <iostream>
using namespace std;

int main(){

int p,l;
int luas;
cout <<"APLIKASI MENGHITUNG LUAS PERSEGI PANJANG"<<endl;
cout <<"------------------------------------"<<endl;
cout << "Masukkan panjang persegi panjang : ";
cin >> p;
cout << "Masukkan lebar persegi panjang : ";
cin >> l;
cout <<"------------------------------------"<<endl;
luas = p*l;
cout << "Luas persegi panjang adalah = " << luas << endl;

return 0;
}

Program Menghitung Luas Segitiga


#include <iostream>
using namespace std;

int main(){

int a,t;
float luas;

cout << "Masukkan panjang alas segitiga: ";


cin >> a;
cout << "Masukkan tinggi segitiga: ";
cin >> t;

luas = 0.5*a*t;
cout << "Luas segitiga adalah " << luas << endl;

return 0;
}
Program Animasi “C++”
#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<windows.h>
#include<stdlib.h>
#include<string.h>

using namespace std;

//prosedur animasi
void delay(void){
int delay;
delay = 1;
while(delay<10000000){
delay ++;
}
}
//gotoxy
void gotoxy(int x, int y){
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
//prosedur huruf c
void c(){
int i,j;
system("color 09");
for(i=24 ; i>=12 ; i--){
gotoxy(i,5);
cout<<"*";
delay();
}

for (i=6 ; i<=15 ; i++){


gotoxy(11,i);
cout<<"*";
delay();
}
for (i=12; i<=24 ; i++){
gotoxy(i,16);
cout<<"*";
delay();
}
}
//prosedur +
void p(){
int i,j;
for(i=45 ; i>=30 ; i--){
gotoxy(i,11);
cout<<"*";
delay();

}
for(i=6 ; i<=16 ; i++){
gotoxy(37,i);
cout<<"*";
delay();
}
}
//prosedur ++
void pp(){
int i,j;
for(i=70 ; i>= 55 ; i--){
gotoxy(i,11);
cout<<"*";
delay();
}
for(i=6 ; i<=16 ; i++){
gotoxy(63,i);
cout<<"*";
delay();
}
}
int main(){
cout<<"membuat animasi c++"<<endl;
c();
p();
pp();
getch();
return 0;
}

You might also like