I have the following function in C(notC++ or C#) that I am trying to fix without the use of arrays , strings and math.h library. Can someone help me to fix the code without using pow and #include respectively. //function #include #include int rotateRight(int num1, int num2); int main () { int num=59232, nTimes=4,k; k=rotateRight(num,nTimes); printf("\n%d",k); return 0; } /* function returning the max between two num1s */ int rotateRight(int num1, int num2) { int a,b,c,Count=0,temp,i; temp=num1; while(temp > 0) { temp = temp/ 10; Count = Count + 1; } for(i=0;i
I have the following function in C(notC++ or C#) that I am trying to fix without the use of arrays , strings and math.h library. Can someone help me to fix the code without using pow and #include<stdio.h> respectively.
//function
#include <stdio.h>
#include<math.h>
int rotateRight(int num1, int num2);
int main () {
int num=59232, nTimes=4,k;
k=rotateRight(num,nTimes);
printf("\n%d",k);
return 0;
}
/* function returning the max between two num1s */
int rotateRight(int num1, int num2) {
int a,b,c,Count=0,temp,i;
temp=num1;
while(temp > 0)
{
temp = temp/ 10;
Count = Count + 1;
}
for(i=0;i<num2;i++){
a=num1/pow(10,Count-1);
c=pow(10,Count-1);
b=num1%c;
num1=b*10+a;
printf("num=%d\n",num1);
}
Step by step
Solved in 5 steps with 3 images