C PRO EXERCISE 2.. 17/07/2012

Written by Unknown on Thursday 19 July 2012 at 09:20

Assalamualaikum,

This is the correction i've made to hafiz coding.


//Writer: Hafiz Yusof
#include <stdio.h>

int main()
{

    int voltage=20;
    int current=6;

    int resistance,remainder;

    resistance=voltage/current;
    remainder=voltage%current;

    printf("the resistance value is %d\n",resistance);
    printf("the remainder value is %d\n",remainder);
    return 0;
}

comment:
overall is ok..
but for the resistance value, it will be perfect if the answer is in floating number.
for example 20 divide by 6 suppose the answer is 3.3333.
in your coding you put it as int which make the answer is 3.

good luck!

0 Responses to "C PRO EXERCISE 2.. 17/07/2012"

Pages

Total Pageviews

Powered by Blogger.

About the author

This blogs is developed by Norhamimi Hamdan. She works as a lecturer for Embedded System Department at Kolej kemahiran Tinggi MARA Beranang. The main purpose of this blogs is to provide information/refferences sources for students of wireless embedded devices and c programming courses.