Header

Wednesday 14 August 2013

Write an algorithm, draw a corresponding flowchart and write an interactive program to convert a binary number to its octal equivalent.

Write an algorithm, draw a corresponding flowchart and write an
interactive program to convert a binary number to its octal equivalent.


C program c program to convert binary to octal

#include<stdio.h>
int main(){
   
    long int binaryNumber,octalNumber=0,j=1,remainder;

    printf("Enter any number any binary number: ");
    scanf("%ld",&binaryNumber);

    while(binaryNumber!=0){
         remainder=binaryNumber%10;
        octalNumber=octalNumber+remainder*j;
        j=j*2;
        binaryNumber=binaryNumber/10;
    }

    printf("Equivalent octal value: %lo",octalNumber);

    return 0;
}

6 comments:

  1. Replies
    1. did u get any algorithm, flow chart...???

      Delete
  2. if you guys have the solved assignment of MCS-011 then send to me pleaaachhh... :P at jaynishad2010@gmail.com

    ReplyDelete
  3. Any of u have the flow chart for this question?????


    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. thins program convert binary to decimel............... dislike.. we want binary to ocatal

    ReplyDelete