Wednesday, 30 December 2015

Program membalik kata di Dev C++

#include <iostream>
#include <string.h>

using namespace std;

int main(int argc, char** argv)
 { system("color b");
 char kal[50];
 int kali;
  cout<<"|=========================|\n";
cout<<"|Menentukan kata Palindrom|\n";
  cout<<"|=========================|\n";
cout<<"|Thedi Wrys  (1500018081) |\n";
cout<<"|=========================|\n\n";
 cout<<"kata :";cin>>kal;
 kali=strlen(kal);

 for(int i=0;i<kali;i++){
  if(kal[i]!=kal[kali-1-i]){
   cout<<"bukan Palindrom:";
   i=kali; }
 
  else{
  cout<<"Palindrom"; i=kali; }
 }
 cout<<endl;
 for(kali=strlen(kal)-1;kali>=0;kali=kali-1)
 {
  cout<<kal[kali]; }
 return 0;
}
Palindrom
thediwrys.blogspot.com

Program menghitung Volume Kubus di Dev C++

#include <iostream>
#include <conio.h>
#include <cstdlib>
using namespace std;
int main(int argc, char** argv) {
system("color a");
float s, vol;

cout<<"|========================|\n";
cout<<"|Menghitung Volume Kubus |\n";
cout<<"|========================|\n";
cout<<"|Thedi Wrys  (1500018081)|\n";
cout<<"|========================|\n \n";

cout<<"masukkan sisi:";cin>>s;
vol=s*s*s;
cout<<"volume nya adalah "<<vol;
 return 0;
}
Volume Kubus
thediwrys.blogspot.com


Program Menghitung Layang-Layang di Dev C++

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class layang_layang
{
 private :
  int t1, t2;

 public:
 int luas()
 {
  return(((t1*t2)*1/2));
 }
 void masuk(int T1, int T2)
 {
  t1=T1;t2=T2;
 }
};
int main(int argc, char** argv)
{
system ("color b");
 layang_layang umbul,umbull;
 int a,b;
cout<<"|========================|\n";
cout<<"|Menghitung Layang Layang|\n";
cout<<"|========================|\n";
cout<<"|Thedi Wrys  (1500018081)|\n";
cout<<"|========================|\n \n";
cout<<"masukkan nilai a:";cin>>a;
  cout<<"masukkan nilai b:";cin>>b;
 umbul.masuk(a,b);
 umbull.masuk(10,5);

 cout<<"Luas Pertama: "<<umbul.luas()<<endl;;
 cout<<"Luas Kedua  : "<<umbull.luas();
 return 0;

}
Layang Layang
thediwrys.blogspot.com

Program Menghitung Luas Segitiga di Dev C++

#include <iostream>
using namespace std;


/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class segitiga{
 float alas,tinggi;
 public:
  void luas(int,int);
  float hasil(void){
   float hasill=(alas*tinggi/2);
   return(hasill);
  }
};
void segitiga::luas(int a,int b){
 alas=a;
 tinggi=b;
}
int main(int argc, char** argv) {
system ("color b");
 segitiga eek;
 float x,y;
cout<<"|========================|\n";
cout<<"|Menghitung Luas Segitiga|\n";
cout<<"|========================|\n";
cout<<"|Thedi Wrys  (1500018081)|\n";
cout<<"|========================|\n \n";

 cout<<"Masukan Tinggi: ";cin>>x;
 cout<<"Masukan Alas: ";cin>>y;
 eek.luas(x,y);
 cout<<"Luas segitiga: "<<eek.hasil();
 return 0;

}
Luas Segitiga
thediwrys.blogspot.com