View: 2711|Reply: 7
|
to ALL PROGRAMMER!! help ME!!
[Copy link]
|
|
aku ade kene uat asgment nih..
aku buat program nie .. untuk convert2 .. tp yg peliknyee bile aku compile die kuar mcm ni:nih output die::
Welcome to MARKOVNIKOV METRIC CONVERSION zone!!
Enter sentence like "x grams in kilograms?":1 millimeters in meters
1.000000 millimeters = 1.000000 millimeters
bile aku letak ape2 convert jer.. mcm centimeters ke, inchi ker.. die tetap nak kuar millimeters gak.. sape2 yg tererr boleyy tak btolkan kesilapan aku nih..
nih code yg aku uat..
nih cume sikit jer
#include <stdio.h>
int main()
{
int metric1, metric2, millimeters, centimeters, meters, kilograms;
float x;
printf("Welcome to MARKOVNIKOV METRIC CONVERSION zone!!\n\n\n");
printf("Enter sentence like \"x grams in kilograms?\":");
scanf("%f %d %d", &x, &metric1, &metric2);
if ( (metric1 = millimeters) && (metric2 = millimeters))
printf("\n%f millimeters = %f millimeters\n", x, x);
else if((metric1 = millimeters) && (metric2 = centimeters))
printf("\n%f millimeters = %f centimeters\n", x, x/10);
else if((metric1 = millimeters) && (metric2 = meters))
printf("\n%f millimeters = %f meters\n", x, x/1000);
else if((metric1 = millimeters) && (metric2 = kilograms))
printf("\nInvalid Conversion\n");
return 0;
} |
|
|
|
|
|
|
|
banyak salah ni...
1. variable millimeters, centimeters, kilometers, meters tak ada definition
2. macam mana dia nak tau millimeters, centimeters etc just from a string input? (kena test nihehe)
3. your if statement salah. sepatutnya metric1 == millimeters, bukan metric1 = millimeters (cuba tengok apa bezanya)
u nak buat conversion program, tapi ni macam ambik orang lain punya kerja aje... coding pun tak complete
a much better implementation is to have a menu-based system to select units to convert, then enter the value, then convert the value |
|
|
|
|
|
|
|
hmm.. ye ke..
1. variable millimeters, centimeters, kilometers, meters tak ada definition <<- nak definition pki ape?? bukan dah declare ke?? boley bg contoh x yg lebey jelas?
2. macam mana dia nak tau millimeters, centimeters etc just from a string input? (kena test nihehe)<-- entah... rase2 belom blaja kot .. tp kene siapkan asgment b4 blaja .. nih nk pki STRING ke??yg #include<string.h>?? kene pki array skalik x?
u nak buat conversion program, tapi ni macam ambik orang lain punya kerja aje... coding pun tak complete <--- mmg x complete.. nih yg siket je.. x amek org laen lerr.. uat sendirik
a much better implementation is to have a menu-based system to select units to convert, then enter the value, then convert the value <--maksudnye???
boley x bg contoh sikit??
tq.. |
|
|
|
|
|
|
|
begini contohnyer adik2.....
belanja kfc kay...
#include <stdio.h>
void main()
{
float nilai_awal=0, result=0;
int pilihan;
printf("1. Milimeter ke Centimeter.\n");
printf("2. Centimeter ke Milimeter.\n");
printf("Sila pilih operasi penukaran :");
scanf("%d",&pilihan);
if(pilihan==1)
{
printf("Sila masukkan nilai awal milimeter :");
scanf("%f",&nilai_awal);
result=nilai_awal/10;
printf("%.3f milimeter = %.3f centimeter",nilai_awal, result);
}
else if(pilihan==2)
{
printf("Sila masukkan nilai awal centimeter :");
scanf("%f",&nilai_awal);
result=nilai_awal*10;
printf("%.3f centimeter = %.3f milimeter",nilai_awal, result);
}
else
{
printf("Bengapla ko ni..");
}
} |
|
|
|
|
|
|
|
hehhehe..
dah tauh dah... shahnazz dah ajor..
tq very much to all....
:lebai: |
|
|
|
|
|
|
|
:malu::malu::malu:
[ Last edited by poyoex at 31-8-2006 12:00 AM ] |
|
|
|
|
|
|
|
Reply #6 poyoex's post
good code simple and nice |
|
|
|
|
|
|
| |
|