# C# Program to Convert Octal to Decimal Number without Array

The Program in C# Program to Convert Octal to Decimal Number without Array is given below:

``````using System;

namespace OctalToDecimalConversion
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello Codeauri Family,enter an octal number to convert into decimal number below: ");
Console.WriteLine("Enter an octal number: ");

int decimalNumber = 0;
int power = 1;

for (int i = octalNumber.Length - 1; i >= 0; i--)
{
int digit = int.Parse(octalNumber[i].ToString());
decimalNumber += digit * power;
power *= 8;
}

Console.WriteLine("Okay,the Decimal representation: " + decimalNumber);
}
}
}
``````

## Output:

Hello Codeauri Family,enter an octal number to convert into decimal number below:
Enter an octal number:
8

Okay,the Decimal representation: 8

## Pro-Tips💡

Here are the step by step execution of above program:

The program starts by using the “System” namespace.

The program defines a namespace called “OctalToDecimalConversion”.

The program defines a class called “Program”.

The program defines the Main method, which is the entry point of the program.

The program writes a message to the console asking the user to enter an octal number.

The program reads the octal number entered by the user and stores it in a string variable called “octalNumber”.

The program initializes two variables: “decimalNumber” and “power”. “decimalNumber” is used to store the converted decimal number, and “power” is used to store the current power of 8 being used in the conversion.

The program uses a for loop to iterate through the octal number from right to left.

The program converts each character of the octal number to an integer, and then multiplies the integer by the current power of 8.

The program adds the result of this multiplication to “decimalNumber”.

The program then multiplies “power” by 8 for the next iteration of the loop.

The program repeats steps 9 to 11 for each character of the octal number.

After the loop finishes, the program writes the converted decimal number to the console.

The program ends by returning 0 from the Main method

### Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

### Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

### Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

## Programming Languages( Types, Pros and Cons)-Codeauri

What are the types or levels of Programming Languages? The types or levels of programming languages are divided into two types: Types Of Programming Languages: 1.Machine-level Language :1st…

## C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

## C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

## C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

## C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

## C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X