A C program to convert an octal number to its equivalent decimal number – IGNOU MCA Assignment 2017 – 18

By | November 11, 2017

MASTER OF COMPUTER APPLICATIONS
Course Code: MCS-011
Course Title : Problem Solving and Programming
Assignment Number : MCA(1)/011/Assign/2017-18
Maximum Marks : 100
Weightage : 25%

Draw a flow chart and write its corresponding C program to convert an octal number to its equivalent decimal number.- IGNOU MCA Assignment 2017 – 18

 

Flowchart:

FlowChart_Octal_2_Decimal

#include<stdio.h>
#include<math.h>
void main ()
{
int oct,dec=0,i=0;
clrscr();
printf(“Enter any Octal number : “);
scanf(“%d”,&oct);
while(oct!=0)
{
dec=dec+(oct%10)*pow(8,i++);
oct=oct/10;
}
printf(“Decimal = %d\n”, dec);
getch();
}

Code:

[codesyntax lang=”c”]

#include<stdio.h>
#include<math.h>
void main ()
{
int oct,dec=0,i=0;
clrscr();
printf(“Enter any Octal number : “);
scanf(“%d”,&oct);
while(oct!=0)
{
dec=dec+(oct%10)*pow(8,i++);
oct=oct/10;
}
printf(“Decimal = %d\n”, dec);
getch();
}

[/codesyntax]

Screen Shots:

C_program_Octal_to_Decimal

C_program_Octal_to_Decimal_Output