- #1
cyber-girl
- 5
- 0
Hello everybody!
Here I wrote simple code for power of n number. At result I need to get an integer value. But my code works only small number of power. (Here in my code is p: 10^p). If I increase p number, then the result will be like this: 2.74*10^6=2.7e+006. But I need the result will be integer value: 2740000.
Thanks!
[C++]#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <conio.h>
using namespace std;
int main(){
int p;
double d;
cout<<"Enter any double number: "<<endl;
cin>>d;
cout<<"Enter power of integer number: "<<endl;
cin>>p;
double a = pow((double)10.0 , p);
d=d*a;
cout<<"Result: "<<d;
getch();
return 0;
}
[/C++]
Here I wrote simple code for power of n number. At result I need to get an integer value. But my code works only small number of power. (Here in my code is p: 10^p). If I increase p number, then the result will be like this: 2.74*10^6=2.7e+006. But I need the result will be integer value: 2740000.
Thanks!
[C++]#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <conio.h>
using namespace std;
int main(){
int p;
double d;
cout<<"Enter any double number: "<<endl;
cin>>d;
cout<<"Enter power of integer number: "<<endl;
cin>>p;
double a = pow((double)10.0 , p);
d=d*a;
cout<<"Result: "<<d;
getch();
return 0;
}
[/C++]