Twitter Update

Create star run program [C]

0 comments

First I think is hard to create this program, that simple one. Here we need file header time.h. can be read by yourself. here I use visual studio, where gotoxy function not exist. we must manually create gotoxy function like a coding below :.


#include<stdio.h>
#include<conio.h>
#include<windows.h>
#include<time.h>
void gotoxy(int x,int y)
{ HANDLE hConsoleOutput;
COORD dwCursorPosition;


dwCursorPosition.X =x;
dwCursorPosition.Y =y;
hConsoleOutput=GetStdHandle (STD_OUTPUT_HANDLE);
SetConsoleCursorPosition (hConsoleOutput,dwCursorPosition);
}
void main()
{
    int i,a=5;
    printf("\n\n\n");
    for(i=0;i<50;i++)
    {
       
        system("cls");
        gotoxy(a,4);
        printf("*");_sleep(70);
        a++;
    }
    a=5;
    for(i=0;i<10;i++)
    {
        system("cls");
        gotoxy(54,a);
        printf("*");_sleep(70);
        a++;
    }
    a=53;
    for(i=0;i<30;i++)
    {
        system("cls");
        gotoxy(a,14);
        printf("*");_sleep(70);
        a--;
    }
    a=14;
    for(i=0;i<10;i++)
    {
        system("cls");
        gotoxy(24,a);
        printf("*");_sleep(70);
        a--;
    }
    a=23;
    for(i=0;i<20;i++)
    {
        system("cls");
        gotoxy(a,5);
        printf("*");_sleep(70);
        a--;
    }
    a=6;
    for(i=0;i<15;i++)
    {
        system("cls");
        gotoxy(4,a);
        printf("*");_sleep(70);
        a++;
    }
    a=5;
    for(i=0;i<60;i++)
    {
        system("cls");
        gotoxy(a,20);
        printf("*");_sleep(70);
        a++;
    }
    a=19;
    for(i=0;i<15;i++)
    {
        system("cls");
        gotoxy(64,a);
        printf("*");_sleep(70);
        a--;
    }
    a=63;
    for(i=0;i<30;i++)
    {
        system("cls");
        gotoxy(a,5);
        printf("*");_sleep(70);
        a--;
    }
    system("cls");
    gotoxy(25,8);
    printf("//PROGRAM SELESAI.......//");
    gotoxy(25,9);
    printf("//PRESS ANY KEY TO EXIT...//");
    getch();
}       
hopefully can help you :)
Lanjutkan..

Create pascal triangle [C++]

0 comments

This is program to create Pascal triangle C++ version. this is the code :


#include<iostream.h>
#include<windows.h>
#include<conio.h>
#define N 13
void gotoxy(int x,int y)
{ HANDLE hConsoleOutput;
COORD dwCursorPosition;

cout.flush();
dwCursorPosition.X =x;
dwCursorPosition.Y =y;
hConsoleOutput=GetStdHandle (STD_OUTPUT_HANDLE);
SetConsoleCursorPosition (hConsoleOutput,dwCursorPosition);
}
void main()
{

int a[N],b,d[N],n,c;
do{
system("cls");
cout<<"Input number: ";
cin>>n;
}while(n>13);

for(b=0;b<n;b++)
{
    gotoxy(35-(b*2),b+2);
    for(c=0;c<=b;c++)
    {    if(c==b||c==0)
            {
                cout<<"   1";
                d[c]=1;
            }
        else {
            d[c]=a[c]+a[c-1];
            cout<<"   "<<d[c];
        }
    }

    for(c=0;c<=b;c++)
    {
        a[c]=d[c];
    }
   
}
getch();

}

Lanjutkan..

Create pascal triangle [C]

0 comments

This program is create pascal triangle by input T of triangle like a picture above, this is the code :

#include<stdio.h>
#include<windows.h>
#include<conio.h>
#define N 13
void gotoxy(int x,int y)
{ HANDLE hConsoleOutput;
COORD dwCursorPosition;


dwCursorPosition.X =x;
dwCursorPosition.Y =y;
hConsoleOutput=GetStdHandle (STD_OUTPUT_HANDLE);
SetConsoleCursorPosition (hConsoleOutput,dwCursorPosition);
}
void main()
{

int a[N],b,d[N],n,c;
do{
system("cls");
printf("input number:");
scanf("%d",&n);
}while(n>13);

for(b=0;b<n;b++)
{
    gotoxy(35-(b*2),b+2);
    for(c=0;c<=b;c++)
    {    if(c==b||c==0)
            {
                printf("   1");
                d[c]=1;
            }
        else {
            d[c]=a[c]+a[c-1];
            printf("%4d",d[c]);
        }
    }

    for(c=0;c<=b;c++)
    {
        a[c]=d[c];
    }
  
}
getch();
}
Hopefully useful ^_^

Lanjutkan..

The program convert decimal numbers to binary [C++]

0 comments

This program can convert from decimal number to binary number by using C++ Language. this is the code :

#include<iostream.h>
#include<conio.h>
#include<windows.h>
void main()
{    ulang:
    int i=0,k,biner[100];
    int desimal;
    char pil;
    cout<<"        ==Program untuk mencari Bilangan biner==";
    cout<<"\n\nMasukan Bilangan desimal yang ingin dikonversikan ke biner : ";
    cin>>desimal;
    for(i=0;i<100;i++)
    {
    biner[i]=desimal%2;
    desimal=desimal/2;
    if(desimal==0)
    {
        break;
    }
    }
    k=i;
    cout<<"\n\n\n";
    for(i=k;i>=0;i--)
    {   
        cout<<biner[i];
    }

    cout<<"\n\nMau Coba lagi y/n : ";
    cin>>pil;
    if(pil=='y')
    {
        system("cls");
        goto ulang;
    }
    else
    {
        getch();
    }
   
   
}



Lanjutkan..

Creating a horizontal equilateral triangle [C++]

0 comments

This program is use C++ Language, where we input T for triangle, in this program is using symbol '*', you can edit by number or else. This is the code :


#include<iostream.h>
#include<conio.h>
void main()
{
    int tinggi;
    int a=0,b,k;
    cout<<"            ==Program untuk membuat segitiga sama sisi=="<<endl;
    cout<<"\nMasukan Tinggi Segitiga : ";
    cin>>tinggi;
    cout<<endl;
    b=tinggi;
    for(int i=0;i<tinggi;i++)
    {
      
        for(k=0;k<=i;k++)
        {
            cout<<'*';
        }

        cout<<endl;
    }

    for(i=tinggi;i>0;i--)
    {
      
        for(k=i-1;k>0;k--)
        {
            cout<<'*';
        }

        cout<<endl;
    }
        getch();
  
}


Hopefully can help :)
Lanjutkan..

Create a simple calculator program [C]

0 comments

This program provides 4 menus namely addition, subtraction, multiplication,divide like a calculator. This is the code :


#include<stdio.h>
#include<windows.h>
#include<conio.h>
void tambah()
{
    system("cls");
    float bil1,bil2,total;
    printf("            ---KALKULATOR PENAMBAHAN---");
    printf("\n\nMasukan bilangan pertama : ");
    scanf("%f",&bil1);
    printf("\nMasukan bilangan kedua   : ");
    scanf("%f",&bil2);
    total=bil1+bil2;
    printf("\n\nHasil penambahannya adalah : %5.2f\n",total);
   
}

void kurang()
{
    system("cls");
    float bil1,bil2,total;
    printf("            ---KALKULATOR PENGURANGAN---");
    printf("\n\nMasukan bilangan pertama : ");
    scanf("%f",&bil1);
    printf("\nMasukan bilangan kedua   : ");
    scanf("%f",&bil2);
    total=bil1-bil2;
    printf("\n\nHasil pengurangannya adalah : %5.2f\n",total);

}

void kali()
{
    system("cls");
    float bil1,bil2,total;
    printf("            ---KALKULATOR PERKALIAN---");
    printf("\n\nMasukan bilangan pertama : ");
    scanf("%f",&bil1);
    printf("\nMasukan bilangan kedua   : ");
    scanf("%f",&bil2);
    total=bil1*bil2;
    printf("\n\nHasil Perkalian adalah : %5.2f\n",total);

}

void bagi()
{
    system("cls");
    float bil1,bil2,total;
    printf("            ---KALKULATOR PEMBAGIAN---");
    printf("\n\nMasukan bilangan pertama : ");
    scanf("%f",&bil1);
    printf("\nMasukan bilangan kedua   : ");
    scanf("%f",&bil2);
    total=bil1/bil2;
    printf("\n\nHasil pembagiannya adalah : %5.2f\n",total);

}

void menu()
{
    system("cls");
    printf("            ---KALKULATOR SEDERHANA---");
    printf("\n\n1.Penambahan.");
    printf("\n2.Pengurangan.");
    printf("\n3.Perkalian.");
    printf("\n4.Pembagian.");
    printf("\n\nKeterangan : Pilihan selain 1,2,3,4 adalah exit program...!\n\n");
   
}

void main()
{
ulang:
    menu();
    fflush(stdin);
    char pil;
    printf("Masukan pilihan anda : ");
    scanf("%c",&pil);
    if(pil=='1')
        {
            tambah();
            printf("Press any key to back to Main menu...");
            getch();
            goto ulang;
           
        }
    if(pil=='2')
        {
            kurang();
            printf("Press any key to back to Main menu...");
            getch();
            goto ulang;
           
        }
    if(pil=='3')
        {
            kali();
            printf("Press any key to back to Main menu...");
            getch();
            goto ulang;
           
        }
    if(pil=='4')
        {
            bagi();
            printf("Press any key to back to Main menu...");
            getch();
            goto ulang;
           
        }
            else
            {
            printf("\n\nProgram akan keluar....\n");
            printf("Press any key to exit program...");
            getch();
           
            }
}

Hopefully can help ^_^
Lanjutkan..

Enter the data string with spaces [C]

0 comments

After a long search ... See also how. enter the data string with spaces by using the function gets. This gets to read 1 line, so different from scanf.
This is the code :


#include<stdio.h>
#include<conio.h>
void main()
{
    char nama[20];
    printf("Input name : ");
    gets(nama); //untuk membaca line menggunakan gets
    printf("\n%s",nama);
    getch();
}

Hopefully can help :)


Lanjutkan..

The program makes a password with the string [C]

0 comments
If you create a password with an integer may be familiar, but if you create a password with a string that uses the header file string.h and function strcmp or so-called string compare.
just to share for my friends. and this is the code :

#include<stdio.h>
#include <string.h>
#include<windows.h>
#include<conio.h>
void main()

{
ulang:
    char pas[10];
    printf("            ---PROGRAM DI KUNCI---");
    printf("\n\nInfo= Passwordnya adalah albert");
    printf("\n\nMasukan Password : ");
    scanf("%s",pas);
    if(strcmp(pas,"albert")==0)
    {
        system("cls");
        printf("Anda berhasil login..");
        printf("\n\nTerima kasih telah menggunakan program ini..\n\n");
        getch();
    }
    else
    {

        printf("Password yang anda masukan salah...!\n");
        printf("silahkan coba lagi..");
        getch();
        system("cls");
        goto ulang;
    }
}

simple right? in strcmp (string compare that 0 is true and 1 is false),
Hope can help ..
Thx :D





Lanjutkan..

The program convert decimal numbers to binary [C]

0 comments

eventually become also its program, this program change decimals into binary numbers consisting of 1 and 0.
for my friends who want to learn how to do altering decimal to binary can simply copy and paste the coding below. you can edit yourself.

#include<stdio.h>
#include<conio.h>
#include<windows.h>
void main()
{    ulang:
    int i=0,k,biner[100];
    int desimal;
    char pil;
    printf("        ==Program untuk mencari Bilangan biner==");
    printf("\n\nMasukan Bilangan desimal yang ingin dikonversikan ke biner : ");
    scanf("%i",&desimal);
    for(i=0;i<100;i++)
    {
    biner[i]=desimal%2;
    desimal=desimal/2;
    if(desimal==0)
    {
        break;
    }
    }
    k=i;
    printf("\n\n\n");
    for(i=k;i>=0;i--)
    {   
        printf("%i",biner[i]);
    }

    printf("\n\nMau Coba lagi y/n : ");
    scanf("%s",&pil);
    if(pil=='y')
    {
        system("cls");
        goto ulang;
    }
    else
    {
        getch();
    }
   
   
}

Hopefully can help ^_^
Lanjutkan..

The program makes an equilateral triangle [C]

0 comments
This program will input the first t of the triangle. and will form an equilateral triangle, you can change into into numbers, or the pascal triangle. or the other . This is the code :


#include<stdio.h>
#include<conio.h>
void main()
{
    int tinggi;
    int a=0,b,k;
    printf("            ==Program untuk membuat segitiga sama sisi==");
    printf("\n\nInput T triangle : ");
    scanf("%i",&tinggi);
    printf("\n");
    b=tinggi;
    for(int i=0;i<tinggi;i++)
    {
      
        for(k=0;k<=b;k++)
        {
            printf("%c",32);
        }
        b--;
        for(int j=0;j<a+1;j++)
        {  
            printf("*");
        }
        printf("\n");  
        a=a+2;
      
    }
        getch();
  
}

Hopefully can help :)
Lanjutkan..

Create program input biodata with struct [C]

0 comments
In this section I create program with Structure, or can be called Struct, First, is definition of variable in struct, then we just use the variable like coding below, It's simple program, if there is not yet understood, just ask me :)


#include<stdio.h>
#include<conio.h>
void main()
{
    struct  {
        char firstname[20];
        char lastname[20];
        char kota[20];
        char telepon[20];
    }  a;
    printf("\n\n            [ Program untuk menginput biodata ] ");
    printf("\n\nMasukan Nama depan anda    : ");
    scanf("%s",&a.firstname);
    printf("\nMasukan Nama belakang anda : ");
    scanf("%s",&a.lastname);
    printf("\nKota anda               : ");
    scanf("%s",&a.kota);
    printf("\nNomor telepon           : ");
    scanf("%s",&a.telepon);

  
    printf("\n\nNama anda adalah %s %s.",a.firstname,a.lastname);
    printf("\nAnda tinggal di %s.",a.kota);
    printf("\nNomor telepon anda %s.",a.telepon);
    printf("\n\n");
    getch();
}

Hopefully useful ^_^
Lanjutkan..

Create Program count volume with C

0 comments

This program can count Volume with menus that we can choose, like a picture above.
and this is the coding :

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<conio.h>
#include<windows.h>
void main()
{
int pil,i,pil2;
float tinggi,alas,panjang,lebar,atas,bawah,sisi,radius,kubus,balok;
char coba;
printf("        ====Selamat Datang di program ini==== \n");
for(i=0;i<=159;i++)
{
printf("%c",220);_sleep(15);
}

printf("Press any key to continue....");
getch();

ulang:
system("cls");
printf("Choose menu : ");
printf("\n1. volume ");
printf("\n2. Luas");
printf("\n3. Exit");
printf("\n\nInput your choose : ");
scanf("%i",&pil);

switch(pil)
{
case 1:
    {
        system("cls");
        printf("Volume apa yang ingin anda hitung : ");
        printf("\n1. Kubus");
        printf("\n2. Balok");
        printf("\n3. kerucut");
        printf("\n4. Tabung");
        printf("\n5. Kembali ke menu utama");
        printf("\n\nMasukan Pilihan anda : ");
        scanf("%i",&pil2);
        switch(pil2)
        {
        case 1:
            {
                system("cls");
                printf("Program mencari volume kubus....");
                printf("\n\nMasukan Sisi daripada Kubusnya : ");
                scanf("%f",&kubus);
                printf("\n\nRumusnya : sisi x sisi x sisi");
                printf("\n\nVolume kubusnya adalah %5.2f.\n",kubus*kubus*kubus);
                printf("Mau coba lagi....? (y/n) ");
                scanf("%s",&coba);
                if(coba=='y')
                {goto ulang;}
                else
                {goto akhir;}
                          
            }
        case 2:
            {
                system("cls");
                printf("Program mencari volume balok...");
                printf("\n\nMasukan Panjang Balok : ");
                scanf("%f",&panjang);
                printf("\nMasukan Lebar Balok : ");
                scanf("%f",&lebar);
                printf("\nMasukan Tinggi Balok : ");
                scanf("%f",&tinggi);
                printf("\n\nRumus Volume Balok : panjang x lebar x tinggi.");
                balok=panjang*lebar*tinggi;
                printf("\n\nVolume Balok : %5.2f.\n",balok);
                printf("Mau coba lagi....? (y/n) ");
                scanf("%s",&coba);
                if(coba=='y')
                {goto ulang;}
                else
                {goto akhir;}
            }
        case 3:
            {
                system("cls");
                printf("Program mencari volume kerucut...");
                printf("\n\nMasukan radius : ");
                scanf("%f",&radius);
                printf("\nMasukan Tinggi : ");
                scanf("%f",&tinggi);
                printf("\n\nRumus Volume Kerucut : 1/3 x phi x (r*r) x tinggi.");
                printf("\n\nVolume Kerucut : %5.2f.\n",(3.14*radius*radius*tinggi)/3);
                printf("Mau coba lagi....? (y/n) ");
                scanf("%s",&coba);
                if(coba=='y')
                {goto ulang;}
                else
                {goto akhir;}
            }
        case 4:
            {
                system("cls");
                printf("Program mencari volume Tabung...");
                printf("\n\nMasukan radius : ");
                scanf("%f",&radius);
                printf("\nMasukan Tinggi : ");
                scanf("%f",&tinggi);
                printf("\n\nRumus Volume Tabung : phi x (r*r) x tinggi.");
                printf("\n\nVolume Tabung : %5.2f.\n",3.14*radius*radius*tinggi);
                printf("Mau coba lagi....? (y/n) ");
                scanf("%s",&coba);
                if(coba=='y')
                {goto ulang;}
                else
                {goto akhir;}
            }
        case 5:
            {
                goto ulang;
                break;
            }
        default:
            {
                break;
            }
        }
    }
case 2:
    {
        system("cls");
        printf("Luas apa yang ingin anda hitung : ");
        printf("\n1. Persegi");
        printf("\n2. Segitiga");
        printf("\n3. Persegi Panjang");
        printf("\n4. Trapesium");
        printf("\n5. Kembali ke menu utama");
        printf("\n\nMasukan Pilihan anda : ");
        scanf("%i",&pil2);
        switch(pil2)
        {
        case 1:
            {
                system("cls");
                printf("Program untuk mencari Luas Persegi ....");
                printf("\n\nMasukan sisi dari persegi : ");
                scanf("%f",&sisi);
                printf("\n\nRumus luas persegi : sisi x sisi.");
                printf("\n\nLuas Persegi : %5.2f.\n",sisi*sisi);
                printf("Mau coba lagi....? (y/n) ");
                scanf("%s",&coba);
                if(coba=='y')
                {goto ulang;}
                else
                {goto akhir;}
            }
        case 2:
            {
                system("cls");
                printf("Program untuk mencari Luas Segitiga ....");
                printf("\n\nMasukan alas segitiga : ");
                scanf("%f",&alas);
                printf("\n\nMasukan tinggi segitiga : ");
                scanf("%f",&tinggi);
                printf("\n\nRumus luas segitiga : 1/2 x alas x tinggi.");
                printf("\n\nLuas Segitiga : %5.2f.\n",alas*tinggi/2);
                printf("Mau coba lagi....? (y/n) ");
                scanf("%s",&coba);
                if(coba=='y')
                {goto ulang;}
                else
                {goto akhir;}
            }
        case 3:
            {
                system("cls");
                printf("Program untuk mencari Luas Persegi panjang ....");
                printf("\n\nMasukan panjang persegi panjang : ");
                scanf("%f",&panjang);
                printf("\n\nMasukan lebar persegi panjang : ");
                scanf("%f",&lebar);
                printf("\n\nRumus luas Persegi Panjang : Panjang x Lebar.");
                printf("\n\nLuas Persegi panjang : %5.2f.\n",panjang*lebar);
                printf("Mau coba lagi....? (y/n) ");
                scanf("%s",&coba);
                if(coba=='y')
                {goto ulang;}
                else
                {goto akhir;}
            }
        case 4:
            {
                system("cls");
                printf("Program untuk mencari Luas Trapesium ....");
                printf("\n\nMasukan sisi atas trapesium : ");
                scanf("%f",&atas);
                printf("\n\nMasukan sisi bawah trapesium : ");
                scanf("%f",&bawah);
                printf("\n\nMasukan Tinggi trapesium : ");
                scanf("%f",&tinggi);
                printf("\n\nRumus luas Trapesium : 1/2 x ((atas+bawah) xtinggi).");
                printf("\n\nLuas Trapesium : %5.2f.\n",((atas+bawah)*tinggi)/2);
                printf("Mau coba lagi....? (y/n) ");
                scanf("%s",&coba);
                if(coba=='y')
                {goto ulang;}
                else
                {goto akhir;}
            }
        case 5:
            {
                goto ulang;
                break;
            }
        default:
            {
                break;
            }
        }
    }
default:
    {
        break;
    }
akhir:
    system("cls");
    for(i=0;i<=79;i++)
    {
        printf("%c",220);_sleep(2);
    }
    printf("        TERIMA KASIH TELAH MENGGUNAKAN PROGRAM INI...\n");
    printf("        CREATED BY : ALBERT...\n\n");
    for(i=0;i<=20;i++)
    {
        printf("%c",220);_sleep(15);
    }
    printf("\n");
    for(i=0;i<=10;i++)
        {
            printf("          %c\n",220);_sleep(15);
        }
    printf("\n\n");
}
}

Lanjutkan..

Create Program Input Name in C

0 comments
This Program is basic. I use Visual Studio to create this simple program. This is the code :


#include<stdio.h>
#include<conio.h>
void main()
{
    char nama[10];
    printf("Input your name : ");
    scanf("%s",nama);
    printf("\n\nYour Name is %s ..!\n\n",nama);
    getch();
}
Lanjutkan..

ABOUT ME

IP
Albert Julius. Powered by Blogger.
Copyright © Albert'Blog