Thursday, January 28, 2016

Calculate The Depreciation with C

For my improvement, I follow the book that guide me into a topic of depreciation. The definition of depreciation itself: method of calculating the cost of tangible assets over it useful life.

For example, if a business purchases a delivery truch with a cost of Rp. 150.000.000 and it is expected to be used for 5 years. The business might have depreciation expense of expected years with the calculation :

first we sum of 5 years  :
 sum = 1+2+3+4+5=15 -->  15 can be formulated as 
 sum = n(n+1)/2
 n is for calculated years

The depreciation of every years can be like this:
  • depreciation of 1 years: 5/15*Rp. 150.000.000 =  Rp. 50.000.000
  • depreciation of 1 years: 4/15*Rp. 150.000.000 =  Rp. 40.000.000
  • depreciation of 1 years: 3/15*Rp. 150.000.000 =  Rp. 30.000.000
  • depreciation of 1 years: 2/15*Rp. 150.000.000 =  Rp. 20.000.000
  • depreciation of 1 years: 1/15*Rp. 150.000.000 =  Rp. 10.000.000

In this learn, We will make a code how to  make a list of depreciation as above 

Here is the code I adopted from C handbook:
     ------------------------------------------------------------

#include<stdio.h>

main ()

{
long int cost;
int i, sum, year;
double deprec;
printf("Cost: ");
scanf("%d", &cost);
printf("Year: ");
scanf("%d", &year);
sum = year * (year+1)/2;
for (i=1;i<=year;i++)
{
deprec = (year + 1.0 - i)/sum*cost;
printf("%2d %.0lf\n", i, deprec);
}
return 0;
}

-------------------------------------------------
The outcome:

Wednesday, January 27, 2016

This program will show a fibonanci series like  1 1 2 3 5 8 13 .......


Tuesday, January 26, 2016

Calculator with C Language

Here I am with one program today :). And here is the code how to make simple calculator. Actually I copied the code from here, and tried to understand it. So simple and make sense. 

Wednesday, January 20, 2016

It's been a while not to fill up this blog. By the way, I'm trying to collect some stuff in order to improve my C learning language.

Living in digital world and improving one of programming language is just like a need #programming #c #language

Foto kiriman Hani (read:honey) (@hanifadinna) pada

Here is the code:

Monday, August 24, 2015

Hello World with LCD Keypad Shield #Learn Arduino

I already found very useful code to display the character with the LCD.




Happy share :)

Saturday, August 22, 2015

Playing The Melody


This weekend I added up some instrument called piezo buzzer. We can play the tone, and as the beginner I started with the example from here . The copied code is here







Friday, August 7, 2015

Controlling the LED Brightness #Learn Arduino



Finally I can go up from blink to another basic of Arduino. In this circuit we can control the brightness of LED with potentiometer.LED brightness is determined from the position knob on the potentiometer.

Some material we need:
  • Arduino (I am using Arduino UNO)
  • LED
  • Potentiometer 10K ohm
  • 330 Ohm resistor
  • PC/laptop
  • Breadboard
  • 6 jumperwire
  • Data cable from Arduino to PC 
 Here is the code that we can simply copying from Arduino IDE example:


the new things we learn in here is "sensorPin =A0". It means that we select the input pin for the potentiometer. To read the value from the sensor we just type "sensorValue = analogRead(sensorPin);"  inside the loop.

Monday, August 3, 2015

Blink LED #Learn Arduino

Up from hello world, now we go little bit further to make the LED blinking.

Some material we need:
  • Arduino (I am using Arduino UNO)
  • LED
  • 330 Ohm resistor
  • PC/laptop
  • Breadboard
  • 3 jumperwire
  • Data cable from Arduino to PC
This is the code, and it's available on the example of Arduino IDE Software with title "Blink"


"high" means 5V supply and make the LED is ON and
"low" meand 0V supply and make the LED is OFF.

The LED will be ON and OFF repeatedly every 1 second  that's because we put the code on the loop.

Sunday, August 2, 2015

Hello World Repeated #Learn Arduino

Modifying from the previous, here I would like to make the "hello world"  appear repeatedly.

---------------------------------------------------------------------------------------------------

//Learn Arduino-Hello world Repeatedly-Hanifadinna

void setup () {
  Serial.begin(9600); //open serial port with speed 9600 bit per second
}

void loop () {
 delay(10000);  // delay time 10 second
 Serial.println("Hello world");  //print out the hello world
}
---------------------------------------------------------------------------------------------------
 Verivy, uplod and we just simply type "ctrl+shift+M" to show the print of "hello world", and then we got this from serial monitor.



To make the hello world appear repeatedly is because we put :

 delay(10000);  // delay time 10 second
 Serial.println("Hello world");  //print out the hello world

inside the void loop, so the hello world will appear repeatedly every 10 second. 

Thursday, July 23, 2015

Hello World #Learn Arduino

The first time we practicing programming ussually with "hello world". Since Arduino both hardware and software, here is how to hello world in Arduino

---------------------------------------------------------------------------------------------------

//Learn Arduino-Hello world

void setup () {
  Serial.begin(9600);//open serial port with speed 9600 bit per second
  delay(10000); // delay time 10 second
  Serial.println("Hello world"); //print out the hello world
}

void loop () {}

---------------------------------------------------------------------------------------------------
 verivy, uplod and we just simply type "ctrl+shift+M" to show the print of "hello world", and then we got this from serial monitor