Show Integer to Hexadecimal,Octal, and Where it's Memory Location.

Thursday, October 8, 2009

This is just want to show You the reader, how to show integer to hexadecimal and octal. And also show the memory location.

/* menampilkan desimal dan heksadesimal */
#include<stdio.h>

int main(void){
    int X;

    printf("Please insert integer number: ");
    scanf("%d", &X);

    printf("%d is %#x in hexadecimal and %o in octal.\n", X, X, X );
    printf("%d is in memory address %p", X, &X);
    printf("\n");

    return 0;
}


Using Array and Functions

Wednesday, October 7, 2009

This is the example:

#include<stdio.h>

void tulisan1(void);
void tulisan2(void);

int main(void){
    tulisan1();
    tulisan2();
}

void tulisan1(void){
    char array1[] =
    {'T','a','m','p','i','l','k','a','n','\0'};
    puts(array1);
}

void tulisan2(void){
    char array2[] = "Tampilkan";
    printf("%s\n", array2);
}

Get Input String From Keyboard

Saturday, October 3, 2009

Now, we'll show how to get input string from keyboard using C. This is the example:

/* Example using gets() and scanf() to input string.
*/
#include<stdio.h>

int main(void){
    char name[15];

    printf("Insert Your name please: ");
    gets(name);
    // or scanf("%s", name);

    printf("Halo, %s. Happy enjoying C. \n", name);
}


Print Hello World Using Assembler

Friday, October 2, 2009

I use MASM and RadAsm-IDE for learning assembler.
This is the example, print "hello world":

[Basic]Using Array

Thursday, October 1, 2009

Now we'll try to using array to find rate of input values. This is the code:

*/ therudi.com Oct 1, 2009 */

#include <stdio.h>
#define MAKS 5

int main(void){

    int i;
    float total = 0, rata;
    float nilai_tes[MAKS];   /* deklarasi array */

    for(i=0; i<MAKS; i++){
        printf("Nilai tes ke-%d : ", i+1);
        scanf("%f", &nilai_tes[i]);

        /* hitung jumlah total nilai */
        total = total + nilai_tes[i];
    }
    rata = total / MAKS;

    /* cetak nilai rata2 */
    printf("\nNilai rata-rata = %g\n", rata);

    return 0;
}


And, this is the example of its execution:

 
 
Copyright © Welcome