This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Senin, 05 Maret 2012

program matriks 4 x4

#include <stdio.h>
#include <stdlib.h>

    int main(){
//Deklarasi Variable
    int i,j;
    printf("===============***********===============\n");
    printf("Program Untuk Membuat Perkalian Matriks\n");
    printf("===============***********===============\n\n");
//input
    int A[4][4]={4,2,2,1,
                 3,3,2,0,
                 2,4,1,0,
                 2,3,1,1};
    printf("Matrik A :\n\n");
    for(i=0;i<4;i++){
       for(j=0;j<4;j++)
       printf(" %d",A[i][j]);
       printf("\n");
       }
       printf("\n");
     
    int S[4][4]={2,4,1,2,
                 1,0,3,4,
                 2,2,0,3,
                 1,3,2,2};
    printf("Matrik S :\n\n");
    for(int i=0;i<4;i++){
       for(int j=0;j<4;j++)
       printf(" %d",S[i][j]);
       printf("\n");
       }
       printf("\n");
//Proses
    printf("Hasil Perkalian Matriks A Dan S : \n\n");
    int D[4][4];
    for(i=0;i<4;i++){
        for(j=0;j<4;j++){
            D[0][0] = (A[0][0]*S[0][0]+A[0][1]*S[1][0]+A[0][2]*S[2][0]+A[0][3]*S[3][0]);
            D[0][1] = (A[0][0]*S[0][1]+A[0][1]*S[1][1]+A[0][2]*S[2][1]+A[0][3]*S[3][1]);         
            D[0][2] = (A[0][0]*S[0][2]+A[0][1]*S[1][2]+A[0][2]*S[2][2]+A[0][3]*S[3][2]);
            D[0][3] = (A[0][0]*S[0][3]+A[0][1]*S[1][3]+A[0][2]*S[2][3]+A[0][3]*S[3][3]);
            D[1][0] = (A[1][0]*S[0][0]+A[1][1]*S[1][0]+A[1][2]*S[2][0]+A[1][3]*S[3][0]);
            D[1][1] = (A[1][0]*S[0][1]+A[1][1]*S[1][1]+A[1][2]*S[2][1]+A[1][3]*S[3][1]);         
            D[1][2] = (A[1][0]*S[0][2]+A[1][1]*S[1][2]+A[1][2]*S[2][2]+A[1][3]*S[3][2]);
            D[1][3] = (A[1][0]*S[0][3]+A[1][1]*S[1][3]+A[1][2]*S[2][3]+A[1][3]*S[3][3]);
            D[2][0] = (A[2][0]*S[0][0]+A[2][1]*S[1][0]+A[2][2]*S[2][0]+A[2][3]*S[3][0]);
            D[2][1] = (A[2][0]*S[0][1]+A[2][1]*S[1][1]+A[2][2]*S[2][1]+A[2][3]*S[3][1]);         
            D[2][2] = (A[2][0]*S[0][2]+A[2][1]*S[1][2]+A[2][2]*S[2][2]+A[2][3]*S[3][2]);
            D[2][3] = (A[2][0]*S[0][3]+A[2][1]*S[1][3]+A[2][2]*S[2][3]+A[2][3]*S[3][3]);
            D[3][0] = (A[3][0]*S[0][0]+A[3][1]*S[1][0]+A[3][2]*S[2][0]+A[3][3]*S[3][0]);
            D[3][1] = (A[3][0]*S[0][1]+A[3][1]*S[1][1]+A[3][2]*S[2][1]+A[3][3]*S[3][1]);         
            D[3][2] = (A[3][0]*S[0][2]+A[3][1]*S[1][2]+A[3][2]*S[2][2]+A[3][3]*S[3][2]);
            D[3][3] = (A[3][0]*S[0][3]+A[3][1]*S[1][3]+A[3][2]*S[2][3]+A[3][3]*S[3][3]);
//Output
            printf(" %d",D[i][j]);
            printf(" ");
        }
    printf("\n");
    }
    printf("\n\n");
    system("pause");
    return 0;
}

program transpose matriks

#include <stdio.h>
#include <stdlib.h>

int main()
{
              
        int y,z;
        printf("===============***********===============\n\n");
        printf("Program Untuk Membuat Matrik Transpose\n\n");
        printf("===============***********===============\n\n");
                       
        int awal[5][5]={1,2,4,6,7,       
                        4,5,6,8,1,
                        7,8,9,0,3,
                        1,2,5,0,8,
                        4,5,6,7,8};
                      
        printf("Matrik awal\n\n");
             for(y=0;y<5;y++){
             for(z=0;z<5;z++)
        printf(" %d",awal[y][z]);
        printf("\n\n");
       
        }       
        printf("\n\n");
        printf("Matriks Transposnya :\n\n");
       

        int b[5][5];            
            for(y=0;y<5;y++){
            for(z=0;z<5;z++){
        b[y][z] = awal[z][y];
       

        printf(" %d",b[y][z]);           //Output
        printf(" ");
        }
        printf("\n\n");
         }
        
printf("\n");
system("pause");
return 0;
}

program huruf besar menggunakan for

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

int main (){
    char c;
    for(c='a';c!='z';){
        c=getch();
        if(c>='A' && c<'Z') printf("%c",c);
    }
   printf("\n\n");
    system("PAUSE");
        return(0);    
}
        

program fibonaci

#include<iostream>
#include<stdio.h>
#include<stdlib.h>

using namespace std;
    int fibonacci(int x)
       {
     
       if(x==1)
           return(0);
       else if(x==2)
           return(1);
       else
           return (fibonacci(x-1)+fibonacci(x-2));
        }

    int main()
        {
       int x;
       cout<<"\nMasukan Jumlah Bilangan Fibonacci Yang Ingin Anda Tampilkan: ";cin>>x;
       for(int y=1;y<=x;y++)
           cout<<fibonacci(y)<<" ";
           cout<<endl;
          
    system("pause");
    return(0);
}

progam untuk mengetahui bilangan prima/bukan

#include <stdlib.h>
#include <stdio.h>
#include <iostream>

using namespace std;
      main()
      {
           
      int w,j,count=0;      
      cout<<"\nMasukkan Sebuah Angka : ";   
      cin>>w;
      for(j=2;j<=w/2;j++)
     
      {
         if(w%j==0)      
         count++;
       }
      
      if(count>0 || w<2)   
         cout<<w<<" Bukan Bilangan Prima\n";
      else cout<<w<<" Adalah Bilangan Prima\n";
        
    system("pause");
    return(0);
}

program bintang bentuk piramida

#include <stdlib.h>
#include <stdio.h>
int main(){

int x,z,D;
printf("--PROGRAM MEMBUAT BINTANG BERBENTUK PIRAMID--\n");
printf("Masukkan jumlah bintang yang dinginkan :"); scanf("%d",&D);

for(x=1; x<=D; x++){
for(z=D; z>=x; z--) printf(" ");
for(z=x;z<2*x;z++) { printf("*"); }
for(z=2*(x-1);z>=x; z--){ printf("*"); }
printf("\n");
}
system("pause");
return 0;
}

program membuat nama kebalik

#include <stdio.h>
#include <stdlib.h>

         int main(){
            printf("Program Membalikkan Kalimat\n");
            char a[6] ={'M','A','L','A','N','G'};
            printf("Nama Semula  :  ");
            for(int y=0; y<6; y++){
                    printf("%c",a[y]);
                    }
            printf("\n");
            printf("Kebalikan    :  ");
            for (int i=5;i>=0;i--){
                printf("%c",a[i]);
            }
            printf("\n\n");
           
            char b[7] ={'M','A','K','A','S','I','H'};
            printf("");
            for(int w=0; w<7; w++){
                    printf("%c",b[w]);
                    }
            printf("\n");
            printf("");
            for (int z=6;z>=0;z--){
                printf("%c",b[z]);
            }
            printf("\n\n");
            system("PAUSE");
            return(0);
}
               

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More