Write a program that calls a function to scale a real number
Write a program that calls a function to scale a real number x into its scientific notation so that 1 x < 10. The amount that x is shifted should be stored into the second argument. Each argument is pass-by-reference. The following function prototype is required. void sci notation(double *x, int *n); Here is an example of when n would be negative
Enter number: 2459.1
x: 2.459
n: -3
Here is an example of when n would be positive
Enter number: 0.0002591
x: 2.591
n: 4
Solution
#include<stdio.h>
#include<math.h>
int main()
{
printf(\"\ enter a number between 1 and 10 :\");
double x;
scanf(\"%lf\",&x);
printf(\"\ enter final shift n :\");
int n;
scanf(\"%d\",&n);
scinotation(&x,&n);
pritnf(\"\ x :%lf\ n : %d\",x,n);
return 0;
}
void scinotation(double *x,int *n)
{
*x=*x*pow(10,*n);
}
