Showing posts with label C. Show all posts
Showing posts with label C. Show all posts

Oct 27, 2011

Make The Program Find The Area And Circumference Of a Circle With c

0 Comment
As a start I'll explain a little history of C + +. C + + is a programming language, computer C + + was developed at Bell Labs (Bjarne Stroustrup) in the early 1970s, the language is derived from the previous language, namely BCL, At first, the language is designed as a programming language that runs on Unix systems, the development, version of the ANSI (American National Standard Institute) C programming language became the dominant version, Though this version is now rarely used in the development of systems and networks as well as for embedded systems. In C + + added new concepts such as classes with properties such as inheritance and overloading. One of the most fundamental differences with the C language is support for the concept of object-oriented programming (Object Oriented Programming).

above is a little description about the C + +, this time we just make the program find the area and circumference of a circle. This is a script-script:
#include <stdio.h>
    int main (void){
        float a,luas,keliling;
           printf("Masukkan Jari-Jari = ");
           scanf("%f",&a);
                luas = 3.14 * a *a ;
                keliling = 2*3.14*a;
           printf("Luas Lingkaran =%.2f\n",luas);
           printf("Keliling Lingkaran =%.2f\n",keliling);
    return 0;
    }
so this tutorial from the coding Edan, if there are errors or wrong words please understandable because it was a newbie.
I shall see in the next tutorial :D  

Oct 24, 2011

Examples Matrix Addition Program

0 Comment
#include <iostream.h>
#include <conio.h>

#define Nmaks 25

typedef int matriks[Nmaks][Nmaks];
void main()
{
 int colA,colB,rowA,rowB,i,j;
 matriks A,B,C;
 char answer;

 do
 {
 do
 {
  clrscr();
  cout<<"MATRIKS A : "<<endl;
  cout<<"Masukkan Jumlah Baris Matriks A : ";
  cin>>rowA;
  cout<<"Masukkan Jumlah Kolom Matriks A : ";
  cin>>colA;
  cout<<endl<<endl;
  cout<<"MATRIKS B : "<<endl;
  cout<<"Masukkan Jumlah Baris Matriks B : ";
  cin>>rowB;
  cout<<"Masukkan Jumlah Kolom Matriks B : ";
  cin>>colB;
 }
 while ((colA!=colB) || (rowA!=rowB));

 clrscr();
 cout<<"Masukkan Nilai Matriks A : "<<endl;
 for(i=1;i<=rowA;i++)
 {
  for(j=1;j<=colA;j++)
  {
   cout<<"A["<<i<<","<<j<<"] = ";
   cin>>A[i][j];
  }
 }

 clrscr();
 cout<<"Masukkan Nilai Matriks B : "<<endl;
 for(i=1;i<=rowB;i++)
 {
  for(j=1;j<=colB;j++)
  {
   cout<<"B["<<i<<","<<j<<"] = ";
   cin>>B[i][j];
  }
 }

 clrscr();
 cout<<endl;
 //Proses Penjumlahan Matriks
 for(i=1;i<=rowA;i++)
 {
  for(j=1;j<=colA;j++)
  {
   C[i][j] = A[i][j] + B[i][j];
  }
 }

 clrscr();
 //Output Matriks A
 gotoxy(1,5);
 cout<<"A = ";
 for(i=1;i<=rowA;i++)
 {
  for(j=1;j<=colA;j++)
  {
   gotoxy(2+4*j,2+2*i);
   cout<<A[i][j];
  }
 }

 //Output Matriks B
 gotoxy(1,13);
 cout<<"B = ";
 for(i=1;i<=rowB;i++)
 {
  for(j=1;j<=colB;j++)
  {
   gotoxy(2+4*j,10+2*i);
   cout<<B[i][j];
  }
 }

 //Output Matriks C
 gotoxy(1,20);
 cout<<"C = ";
 for(i=1;i<=rowA;i++)
 {
  for(j=1;j<=colA;j++)
  {
   gotoxy(3+4*j,17+2*i);
   cout<<A[i][j];
  }
 }

 gotoxy(17,20);
 cout<<" + ";
 for(i=1;i<=rowB;i++)
 {
  for(j=1;j<=colB;j++)
  {
   gotoxy(18+4*j,17+2*i);
   cout<<B[i][j];
  }
 }

 gotoxy(32,20);
 cout<<" = ";
 for(i=1;i<=rowA;i++)
 {
  for(j=1;j<=colA;j++)
  {
   gotoxy(33+4*j,17+2*i);
   cout<<C[i][j];
  }
 }

 getch();
 clrscr();
 cout<<"== PROGRAM SELESAI =="<<endl<<endl;
 cout<<"Mau Melakukan Perhitungan Lagi?? [Y/T]"; cin>>answer;
 }
 while ((answer == 'y') || (answer == 'Y'));
}