mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 13:31:21 +03:00
improved code
This commit is contained in:
parent
18d86c9f73
commit
6c5128e2cd
@ -9,9 +9,9 @@ int three_digits(int n)
|
|||||||
for(int i=0; i<3; i++)
|
for(int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
r = n%10;
|
r = n%10;
|
||||||
d = d + r * p;
|
d += r * p;
|
||||||
p = p * 10;
|
p *= 10;
|
||||||
n = n / 10;
|
n /= 10;
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ int main(void)
|
|||||||
|
|
||||||
else td = binary_num;
|
else td = binary_num;
|
||||||
|
|
||||||
binary_num = binary_num / 1000;
|
binary_num /= 1000;
|
||||||
|
|
||||||
d = 0, base =1;
|
d = 0, base =1;
|
||||||
|
|
||||||
@ -38,13 +38,13 @@ int main(void)
|
|||||||
while(td > 0)
|
while(td > 0)
|
||||||
{
|
{
|
||||||
remainder = td % 10;
|
remainder = td % 10;
|
||||||
td = td / 10;
|
td /= 10;
|
||||||
d = d + (base * remainder);
|
d += (base * remainder);
|
||||||
base = base * 2;
|
base *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = res + d * ord; // Calculating the octal value
|
res += d * ord; // Calculating the octal value
|
||||||
ord = ord * 10;
|
ord *= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nOctal equivalent is: %d", res);
|
printf("\nOctal equivalent is: %d", res);
|
||||||
|
Loading…
Reference in New Issue
Block a user