bahasa c
Welcome guest, is this your first visit? Create Account now to join.
  • Login:

Welcome to the CHIP Forum.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

+ Reply to Thread
Results 1 to 6 of 6

Thread: bahasa c
  
Bookmark and Share

  1. #1
    Join Date
    Jul 2009
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    bahasa c



    alow... gw pengguna bahasa c baru ne.. and mao tanya cara pengguna if di bahsa c... bagi da yang tao tolong kasih tao y... klo bisa sexan dengan contoh kasus ooo0.. kirim aja ke Joko_ang@rocketmail.com or balas di forum nilll..
    penting banget ne... buat gw .. please

    with regard,
    joko

  2. #2
    Join Date
    Jun 2005
    Location
    Unknown
    Posts
    2,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    28

    Re: bahasa c



    If (Kondisi)
    {
    Statement 1;

    }

    ===================================

    #include <stdio.h>
    #include <conio.h>
    Void main()
    {
    int x;
    printf("1. Nilai Bahasa Inggris\n");
    printf("2. Nilai Matematika\n");
    scanf("%d",&amp;amp;x);
    if (x==1)
    printf("Nilainya 85");
    if (x==2)
    printf("Nilainya 90");
    getch();
    }
    ===================================

    If (Kondisi)
    {
    Statement 1;
    Statement 2;
    }
    else
    {
    Statement 3;
    Statement 4;
    Statement dst;
    }

    ===================================

    #include <stdio.h>
    #include <conio.h>
    Void main()
    {
    int x;
    printf("1. Nilai Bahasa Inggris\n");
    printf("2. Nilai Matematika\n");
    scanf("%d",&amp;x);
    if (x =1)
    {
    printf("Nilainya 85");
    }
    if (x==2)
    {
    printf("Nilainya 90");
    }
    else
    {
    printf("Tidak ada nilainya");
    }
    return 0;
    }

    ===================================

    switch(skor)
    {
    case 1:
    break;
    case 2:
    break;
    .
    }

    ===================================

    #include <stdio.h>
    #include <conio.h>
    Void main()
    {
    int x;
    printf("1. Nilai Bahasa Inggris\n");
    printf("2. Nilai Matematika\n");
    scanf ("%d", &amp;x)
    switch (x)
    {
    {
    case 1: printf("Nilainya 85"); break;
    case 2: printf("Nilainya 90"); break;
    default: printf("Tidak ada nilainya");
    }
    Getch();
    }

    ===================================

    contoh lain:
    #include <stdio.h>
    #include <conio.h>
    //Program untuk menghitung luas lingkaran
    main()
    {
    float pi = 3.1415;
    float r;
    printf ("Jari-jari lingkaran = ");
    scanf ("%f", &amp;r);
    printf ("Luas lingkaran = %f", pi * r * r);
    getch();
    }
    #include <stdio.h>
    #include <conio.h>
    //Program untuk mengetahui nilai suatu inputan
    main()
    {
    int a;
    printf ("Ketikkan suatu nilai integer :");
    scanf ("%d", &amp;a);
    if (a > 0)
    {
    printf ("Nilai yang anda masukkan bernilai positif %d ", a);
    }
    else if (a == 0)
    {
    printf ("Nilai Nol %d ", a);
    }
    else /* a > 0 */
    {
    printf ("Nilai yang anda masukkan bernilai negatif %d ", a);
    }
    getch();
    }
    #include <stdio.h>
    #include <conio.h>
    #include <math.h>
    //menghitung keliling segitiga
    main()
    {
    int a,b,c,K;
    printf("Masukan nilai a = ");
    scanf("%i",&amp;a);
    printf("Masukan nilai b = ");
    scanf("%i",&amp;b);
    printf("Masukan nilai c = ");
    scanf("%i",&amp;c);
    K = (a+b+c);
    printf("Keliling segitiga adalah %i", K);
    getch();
    }
    Last edited by Mr.J; 30-07-2009 at 19:54.
    ~ ajari dia mengerti kita dan jangan memaksakan kehendak kita padanya ~



    Katakanlah yang benar itu benar, dan yang salah itu salah
    walau itu terasa pahit.


  3. #3
    Join Date
    Jul 2009
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: bahasa c



    ow... thank a lot... and bisakah anda jelaskan dikit... just like perbedaan antara fomat string and numbering dalam if.. secara umum shi gw da tao cuma karg cara pembelian nilai ... kata dosennya masih banyak yang salah deh...
    and dia tu... ngxx mao jelaskan lage.... cerewek xxx,,, hehege
    but anywere .. thank you oo00...

  4. #4
    Join Date
    Nov 2006
    Posts
    3,680
    Thanks
    1
    Thanked 1 Time in 1 Post
    Rep Power
    40

    Re: bahasa c



    Quote Originally Posted by joko_ang View Post
    ow... thank a lot... and bisakah anda jelaskan dikit... just like perbedaan antara fomat string and numbering dalam if.. secara umum shi gw da tao cuma karg cara pembelian nilai ... kata dosennya masih banyak yang salah deh...
    and dia tu... ngxx mao jelaskan lage.... cerewek xxx,,, hehege
    but anywere .. thank you oo00...
    maksudnya apa ya??
    tapi yg jelas klo string d C itu sbnernya cuma array or char, jadi ga bisa pke == buat kondisional gitu

    Code:
    char string[64] = "Hello world";
    int angka = 50;
    
    if (angka == 50)
        printf("angka == 50 : %d\n", angka);
    else
        printf("angka != 50 : %d\n", angka);
    
    if (strcmp(string, "hello world") == 0)
        printf("string != \"hello world\" (case sensitive) : %s", string);
    else if (stricmp(string, "hello world") == 0)
        printf("string == \"hello world\" (case insensitive) : %s", string);
    else
        printf("string != \"hello world\" : %s", string);
    bakal keluarnya

    Code:
    angka == 50 : 50
    string == "hello world" (case insensitive) : Hello world
    tapi klo pke if (string == "Hello world"), bakal compiler error

  5. #5
    Join Date
    Jun 2005
    Location
    Unknown
    Posts
    2,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    28

    Re: bahasa c



    coba aja di compile dulu, dengan 1 metode dan cara yg beda2 dan lihat hasilnya

    dari situ cobalah utk bisa menarik kesimpulan perbedaan dan efektifitas coding mana yg lebih baik utk digunakan.

    keep try and try to learning

  6. #6
    Join Date
    Jul 2009
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: bahasa c



    ok...tq a lot .....


 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts