program merubah bilangan bulat menjadi bilangan scientific C++
#include <iostream>
#include <cstdlib>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
double a,b,c;
a = 12.3141592654;
b = 2004.0;
c = 1.23E1;
cout.precision(4);
cout<<a<<"\t"<<b<<"\t"<<c<<endl;
cout<<fixed<<a<<"\t"<<b<<"\t"<<c<<endl;
cout<<scientific<<a<<"\t"<<b<<"\t"<<c<<endl;
return 0;
}
output :

Tidak ada komentar:
Posting Komentar