Professional Documents
Culture Documents
HARIDWAR, UK
ASSIGNMENTS NUMBER #05
Name :- Gautam Singh Kushwaha
Branch:- ECE
Roll no :- 206320055
ASSIGNMENTS NUMBER#05
#include<stdio.h>
#include<math.h>
Int main(){
Int a[10],n,I;
System (“cls”);
Scanf(“%d”,&n);
For(i=0;n>0;i++)
A[i]=n%2;
N=n/2;
For(i=i-1;i>=0;i--)
Printf(“%d”,a[i]);
Return 0;
}
OUTPUT -
Enter the decimal number: 19
2. C PROGRAM TO CONVERT DECIMAL NUMBER TO OCTAL NUMBER
#include <stdio.h>
#include <math.h>
Return 0;
}
While (decimalNumber != 0)
{
octalNumber += (decimalNumber % 8) * I;
decimalNumber /= 8;
I *= 10;
}
Return octalNumber;
}
OUTPUT-
Enter the decimal number: 20
3. C PROGRAM TO CONVERT OCTAL NUMBER TO DECIMAL NUMBER
#include <stdio.h>
#include <math.h>
While(octalNumber != 0)
{
decimalNumber += (octalNumber%10) * pow(8,i);
++I;
octalNumber/=10;
}
I = 1;
Return decimalNumber;
}
OUTPUT-
Enter the octal number: 22
4. C PROGRAM TO CONVERT OCTAL NUMBER TO BINARY NUMBERS
#include <stdio.h>
#include <math.h>
While(octal != 0)
{
Decimal += (octal%10) * pow(8,i);
++I;
Octal/=10;
}
I = 1;
While (decimal != 0)
{
Binary += (decimal % 2) * I;
Decimal /= 2;
I *= 10;
}
Return binary;
}
Int main()
{
Int octal;
Return 0;
}
OUTPUT-
Enter the octal number: 11
Enter an octal number :
Binary Equiva 1ent : 1001