Berikut sebuah program yang sedikit rumit, saya kemas sedemikian rupa supaya dimengerti dan mudah dipahami, Menghitung Parameter Geometri dari Bangun Dasar dan Bangun Ruang
/*Program untuk menghitung geometri dari lingkaran
#Segitiga, kubus, dan bola (Diameter, Keliling, Luas
#area, volume, dan lain2)*/
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
/*Lingkaran */
printf("Lingkaran\n-----------------------\n");
int r,D;
float PHI,l_ling,k_ling;
PHI = 3.14;
printf("Masukkan nilai r: ");scanf("%d",&r);
D = 2 * r;
l_ling = PHI * r * r;
k_ling = 2 * PHI * r;
printf("\n\nJari - jari = %d",r);
printf("\nDiameter = %d\n",D);
printf("\nLuas Lingkaran = %5.2f\n",l_ling,l_ling);
printf("Keliling Lingkaran = %5.2f\n",k_ling,k_ling);
/*segitiga */
printf("\nSegitiga\n-----------------------\n");
int a,t;
float c,l_segi,k_segi;
printf("Masukkan nilai Alas: ");scanf("%d",&a);
printf("Masukkan nilai Tinggi: ");scanf("%d",&t);
c = sqrt(a*a+t*t);
l_segi = 0.5*a*t;
k_segi = a+t+c;
printf("\nAlas = %d\n",a);
printf("Tinggi = %d\n",t);
printf("Sisi miring = %5.2f\n",c);
printf("\nLuas Segitiga = %5.2f\n",l_segi);
printf("Keliling Segitiga = %5.2f\n",k_segi);
/*Kubus*/
printf("\nKubus\n----------------------------\n");
int rusuk,l_perm,v_kubus;
printf("Masukkan nilai Rusuk: ");scanf("%d",&rusuk);
l_perm = rusuk * rusuk;
v_kubus = rusuk * rusuk * rusuk;
printf("\nRusuk = %d\n",rusuk);
printf("\nLuas Permukaan Kubus = %d\n",l_perm);
printf("Volume Kubus = %d\n",v_kubus);
/*Bola*/
printf("\nBola\n-----------------------------\n");
int r2,D2;
float l_bola,v_bola;
printf("Masukkan nilai Jari - jari: ");scanf("%d",&r2);
D2 = r2 * 2;
l_bola = 4 * PHI * r2 * r2;
v_bola = (4/3) * PHI * r2 * r2 * r2;
printf("\nJari - jari = %d\n",r2);
printf("Diameter = %d\n",D2);
printf("\nLuas Bola = %5.2f\n",l_bola);
printf("Volume Bola = %5.2f\n",v_bola);
}
/*Script Code By TooCool Games @txtoocool.blogspot.com
Program yang digunakan adalah Turbo C++
/*Program untuk menghitung geometri dari lingkaran
#Segitiga, kubus, dan bola (Diameter, Keliling, Luas
#area, volume, dan lain2)*/
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
/*Lingkaran */
printf("Lingkaran\n-----------------------\n");
int r,D;
float PHI,l_ling,k_ling;
PHI = 3.14;
printf("Masukkan nilai r: ");scanf("%d",&r);
D = 2 * r;
l_ling = PHI * r * r;
k_ling = 2 * PHI * r;
printf("\n\nJari - jari = %d",r);
printf("\nDiameter = %d\n",D);
printf("\nLuas Lingkaran = %5.2f\n",l_ling,l_ling);
printf("Keliling Lingkaran = %5.2f\n",k_ling,k_ling);
/*segitiga */
printf("\nSegitiga\n-----------------------\n");
int a,t;
float c,l_segi,k_segi;
printf("Masukkan nilai Alas: ");scanf("%d",&a);
printf("Masukkan nilai Tinggi: ");scanf("%d",&t);
c = sqrt(a*a+t*t);
l_segi = 0.5*a*t;
k_segi = a+t+c;
printf("\nAlas = %d\n",a);
printf("Tinggi = %d\n",t);
printf("Sisi miring = %5.2f\n",c);
printf("\nLuas Segitiga = %5.2f\n",l_segi);
printf("Keliling Segitiga = %5.2f\n",k_segi);
/*Kubus*/
printf("\nKubus\n----------------------------\n");
int rusuk,l_perm,v_kubus;
printf("Masukkan nilai Rusuk: ");scanf("%d",&rusuk);
l_perm = rusuk * rusuk;
v_kubus = rusuk * rusuk * rusuk;
printf("\nRusuk = %d\n",rusuk);
printf("\nLuas Permukaan Kubus = %d\n",l_perm);
printf("Volume Kubus = %d\n",v_kubus);
/*Bola*/
printf("\nBola\n-----------------------------\n");
int r2,D2;
float l_bola,v_bola;
printf("Masukkan nilai Jari - jari: ");scanf("%d",&r2);
D2 = r2 * 2;
l_bola = 4 * PHI * r2 * r2;
v_bola = (4/3) * PHI * r2 * r2 * r2;
printf("\nJari - jari = %d\n",r2);
printf("Diameter = %d\n",D2);
printf("\nLuas Bola = %5.2f\n",l_bola);
printf("Volume Bola = %5.2f\n",v_bola);
}
/*Script Code By TooCool Games @txtoocool.blogspot.com
Program yang digunakan adalah Turbo C++
No comments:
Post a Comment