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 pertukaran angka

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

void tukar_angka(int *pw,int *py)
{
int temp=*pw;
*pw=*py;
*py=temp;
}
int main(void){
int a=90,b=75;

printf("Sebelum Pertukaran Angka:\n");
printf("\nNilai 1=%d\n",a);
printf("Nilai 2=%d\n",b);
printf("\n");
tukar_angka(&a, &b);

printf("Setelah Pertukaran Angka:\n");
printf("\nNilai 1=%d\n",a);
printf("Nilai 2=%d\n",b);
printf("\n");

getch();
return 0;
}

program array menampilkan nilai

#include<stdio.h>
#include<conio.h>
int main(){
int maks, min;
int *p, matriks []={12,75,2,9,8,30,45,79,90,13,25,9};

for (int z=0;z<12;z++){
printf("Tampilan_Array : %d ",matriks [z]);
printf("\n"); }

for (int b=0;b<12;b++){

if(maks<matriks[b]) maks= matriks [b];
else
if(min>matriks [b]) min= matriks [b];

}
p=matriks;
printf("\nElemen   Alamat   Nilai\n");
printf("==============================\n");
for (int c=0;c<12;c++){
printf("%4d    %p    %d\n",c,p,*p);
p++;
}

printf("\n======================\n");
printf("Nilai Terbesar : %d\n",maks);




getch();
return(0);
}

Program Statistik Untuk Menghitung Nilai Rata-Rata,Maksimum,Minimum

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

int main(){
int maks, min;
double total;
double rata;
int w[]= {2,7,20,9,30,125,200,210,45,798,90,137,25,27,90,8,9,3,1,56};
total=0;
printf("===================================================================\n");
printf("Program Statistik Untuk Menghitung Nilai Rata-Rata,Maksimum,Minimum\n");
printf("===================================================================\n");
for (int y=0;y<20;y++){
printf("tampilan_array : %d ",w[y]);
printf("\n"); }

for (int y=0;y<20;y++){

if(maks<w[y]) maks= w[y];
else
if(min>w[y]) min= w[y];
total = total + w[y];
}
printf("\n======================\n");
printf("Nilai Maks : %d\n",maks);
printf("Nilai Min  : %d\n",min);
rata = total/20; printf ("Rata-Rata  : %2f \n",rata);
printf("======================\n");

getch();
return(0);
}

program nama

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

int main(){
    printf("program mengambil n karakter dari kanan dengan kata yang diberikan\n\n");
printf("Nama Lengkap  =%s\n",strpbrk("xxWILLIBAGUS","WILLI"));
char str [100]="WILLIBAGUS";
printf("Nama Panggilan=%s\n",strstr(str,"BAGUS"));
getch();
return 0;
}

program membuat rata2 menggunakan for

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

int main() {
    int x,sigma,i,n;
    float xrt;
    char c;
    for(c='1';c!='5';){
    system("cls");
    printf("================================\n");
    printf("**PROGRAM MENGHITUNG RATA-RATA**\n");
    printf("================================\n");
    printf("Masukan jumlah data: \n");scanf("%d",&n);
    printf("Masukan Elemen data:\n");
    sigma = 0;
    for(i=1; i<=7; i++){
             printf("data ke-%03d: ",i); scanf ("%d",&x);
             sigma = sigma + x;
             }
    xrt=(float)sigma / n;
    printf("Total Data : %d\n",sigma);
    //menunjukan total/jumlah dari data2nya
    printf("Rata-Rata  : %f\n",xrt);
    //rata2 menunjukan nilai semua dijumlah kemudian dibagi sebanyak jumlah data
    printf("================================\n");
    printf("\n\n");
    system("pause");
    return(0);
}}   

program perkalian dngn for

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

int main () {
    int i,j,k;
    for(i=1;i<=9;i++) {
       for(j=1;j<=5;j++){
         k=i*j;
         printf("%dx%d=%d\t ",j,i,k);
       }
       printf("\n");
    }
    printf("\n\n");
    system("pause");
    return(0);
}

program menghitung luas Persegi Panjang,Lingkaran ,Segitiga

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

int main () {
    char c='1';
    int p,l;
  
   while  (c!='5'){
    system("cls");
    printf("******************************\n");
    printf("********Menghitung Luas*******\n");
    printf("******************************\n");
    printf("*   1. Persegi Panjang        \n");
    printf("*   2. Persegi                \n");
    printf("*   3. Lingkaran              \n");
    printf("*   4. Segitiga               \n");
    printf("*   5. selesai                \n");
    printf("******************************\n");
    printf("*   Pilih Salah Satu! ");
    do{
        c= getch ();
        if(c>='1'&&c<='5') printf("%c",c);
    }
    while(c<'1'||c>'5');
    printf("      *\n");
    printf("******************************\n\n\n");
    switch(c){
        case '1': printf("Panjang : "); scanf("%d",&p);
                  printf("lebar   : "); scanf("%d",&l);
                  printf("Luas    : %d\n\n",p*l);
                  break;
        case '2': printf("Panjang sisi: "); scanf("%d",&p);
                  printf("Luas    : %d\n\n",p*p);
                  break;
        case '3': printf("Diameter: "); scanf("%d",&p);
                  printf("Luas    : %d\n\n",(float)22/7*p*p/4);
                  break;
        case '4': printf("Alas    : "); scanf("%d",&p);
                  printf("lTinggi : "); scanf("%d",&l);
                  printf("Luas    : %d",(float)p*l/2);
                  break;
             }
     getch();
    }
    printf("\n\n");
    system("pause");
    return(0);
}

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More