Skip to content

Conversation

@shiwangi123456
Copy link

#include <math.h>
#include <stdio.h>
int convert(long long bin);
int main() {
long long bin;
printf("Enter a binary number: ");
scanf("%lld", &bin);
printf("%lld in binary = %d in octal", bin, convert(bin));
return 0;
}

int convert(long long bin) {
int oct = 0, dec = 0, i = 0;

// converting binary to decimal
while (bin != 0) {
    dec += (bin % 10) * pow(2, i);
    ++i;
    bin /= 10;
}
i = 1;

// converting to decimal to octal
while (dec != 0) {
    oct += (dec % 8) * i;
    dec /= 8;
    i *= 10;
}
return oct;

}

heydc7 and others added 30 commits October 18, 2020 14:44
Create sum of elements in a array.....
Create sum of elements in a array......
optimise program for fibonacci siries
Create Dijkstras Algorithm for Single Source Path-C++
Create Linear Search Using Recursion-C++
Create Sum of elements in a array..
Create C program for febonacci siries
Optimized code for finding d smallest element in array in a quick way
optimized 2D Matrices  using C
code for ASCII
I have import math and used different methods of it to print ceiling and floor value.
left rotate array using c
Create binary search tree
Create valleys counting
Create java inheritance
Optimised code of length of string in a quick way
Dining Philosopher Problem implemented with C language
C++ program to find no of nodes in BST
C++ Program for Deletion of BST(Binary Search Tree)
C++ Program for Implementing Graph Data Structure
minor changes
heydc7 and others added 30 commits October 19, 2020 12:30
Update Program to add two numbers in pyhton
Create Program to print Fibonnaci Series new
Create A string is palindrome or not
Program to count vowels in a string by java
Create C program to check if an integer is prime or not
Create  C program to get input from a user using scanf
Create using if else control instructions
Create command line arguments in c
Create Using comments in a program in c
Create using structures in C programming
code for sum of elements in array in c.
factorial of nos in c.
power of number in c.
length of the string in c
array reverse in c
binary to decimal converter in c
multiplication of matrices in c
matrix multiplication in c.
binary to octal in c
to find fabonacci series
to find fabonacci series
Multiplication of matrix in c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.