void toOctal(int num){
int i, temp, temp2, q, ar[100], count=0, h;
for (i=0;num>0;i++){
q=num;
num=num/8;
temp=num;
temp2=temp*8;
temp=q-temp2;
count++;
ar[i]=temp;
}
for(h=0;h<count;h++){
printf("%d", ar[count-1-h]);
}
}
int toDecimal(char *num){
int b, k, m, n;
int len, sum = 0;
len = strlen(num) - 1;
for(k = 0; k <= len; k++)
{
n = (num[k] - '0');
if ((n > 8) || (n < 0))
{
printf("\n\n ERROR! Octal has only 0 to 7!\n");
return (0);
}
for(b = 1, m = len; m > k; m--)
{
b *= 8;
}
sum = sum + n * b;
}
return(sum);
}
About this blog
These codes here are just based on my own knowledge learned from my IT subjects. I know there are more ways that this draft codes can be enhance, so..
Please feel free to comment & suggest.. Suggest Codes which makes my existing codes simpler.. Thanks!
Archives
Categories
Making Life Simple w/ Programming
Links
- w3schools.com
- Java & Textpad Setup Guide 2
- Java & Textpad Setup Guide
- ASCII Alphabet Characters
- File Handling - Forum
- File Handling - Tutorial 0.1
- File Handling - Tutorial 0.2
- Bin-Dec Conversion - Forum
- Use of getch(), getche(), & getchar()
- The C Book
- SEO
- Common C programming errors
- Tutorial - Array Functions
- August Council Tutorial - c
- C language tutorials
- cprogramminglanuage.net
0 comments