Need Help on my project

hello, i'm very confuse about my project. anyone can help?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream.h>
#include <conio.h>

double hasilnya(double bilangan, int banyak)
{
 double jawaban;
 jawaban=bilangan;
 cout.setf(ios::fixed);
 cout.setf(ios::showpoint);
 cout.precision(banyak);
 return (jawaban);
}

int main()
{
int banyak;
double bilangan,hasil;
cout<<"Masukkan bilangan : ";
cin>>bilangan;
cout<<"Berapa banyak nilai desimal? ";
cin>>banyak;
hasil=hasilnya(bilangan,banyak);
cout<<"Bilangan sebelum dientri : " <<bilangan<<endl
    <<"Bilangan sesudah dientri : " <<hasil<<endl;

getch ();
return 0;
}


is there any problems with my script?
i wanna make this project work correctly
when i type "Masukkan bilangan"(put numbers in): 1314232.321323313241
"Berapa banyak nilai desimal?"(how many decimal do you want?): 4
"Bilangan sebelum dientri"(the numbers before input): 1314232.3213 --> WRONG
"Bilangan sesudah dientri"(the numbers after input) : 1314232.3213 --> TRUE

how to correct 1314232.3213 become 1314232.321323313241 ??
i'm using borland C++
thanks b'4
Last edited on
Try to use the printf function. Hope it can help. :)

 
printf("Bilangan sebelum dientri : %.9f",bilangan); //or '%f' 
@Jackson Marie (10)

Bad advice. This is a C++ forum.

I see this as another attempt at trolling.
it's work :D
but, can we use cout??
Yes:

cout.precision

Read about it in the reference section - top left of this page.

still not work correctly -_-
Topic archived. No new replies allowed.