Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- float f1,f2,ans;
- printf("Enter two floating point numbers ");
- scanf("%f %f",&f1,&f2);
- int e1 , e2;
- printf("Enter two integer numbers ");
- scanf("%d %d",&e1,&e2);
- // printf("\n%d %d\n",e1,e2);
- printf("\nEnter operator 1 = +, 2 = -, 3 = *, 4 = / ");
- int c ;
- scanf("%d",&c);
- if (e1>e2){
- while(e1!=e2){
- f2/=10;
- e2++;
- }
- }
- else if (e1<e2){
- while(e1!=e2){
- f1/=10;
- e1++;
- }
- }
- printf("\n%f %d %f %d \n",f1,e1,f2,e2);
- if(c==1) ans = f1+f2;
- else if (c==2) ans = f1-f2; // here
- else if (c==3) ans = f1*f2;
- else if (c==4) ans = f1/f2;
- else {
- printf("Wrong choice");
- return 0;
- }
- int e=e1;
- if (ans>=1){
- while(ans>=1){
- ans/=10;
- e++;
- }
- }
- else if (ans<=0.1){
- while(ans<=0.1){
- ans*=10;
- e--;
- }
- }
- printf("Result %f X 10^%d",ans,e);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement