0% found this document useful (0 votes)
18 views11 pages

Csea 20 PPT

This document describes a number conversion system that allows conversion between decimal, binary, and octal number systems. It contains functions to convert decimal to binary, binary to decimal, and octal to binary. The code uses algorithms specific to each conversion type to accurately and efficiently transform between the different numeral systems.

Uploaded by

pruthvinathr97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views11 pages

Csea 20 PPT

This document describes a number conversion system that allows conversion between decimal, binary, and octal number systems. It contains functions to convert decimal to binary, binary to decimal, and octal to binary. The code uses algorithms specific to each conversion type to accurately and efficiently transform between the different numeral systems.

Uploaded by

pruthvinathr97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Number

conversion system

Team : 20
Team members :
23H51A0530 Karam Abhinash
23H51A0534 Katkuri Sathyanarayana
23H51A0546 Mothuku Shalini
23H51A0561 Thupakula Naga Sai Gagan
Click Introduction
to edit Master title
: a style
look in conversion system

This number conversion system provides a streamlined method for converting


between decimal, binary, and octal numeral systems. Its functionalities include
transforming decimal numbers into their binary counterparts, converting
binary values to decimal representations, and facilitating the conversion of
octal numbers to their binary equivalents. The code operates by implementing
algorithms specific to each conversion type, ensuring accurate and efficient
transformations between these fundamental numeral systems. With this tool,
users can seamlessly navigate between different numerical bases, enabling
better comprehension and manipulation of diverse number representations
within various fields such as computer science, mathematics, and digital
electronics.
2 2
#include <stdio.h>
#include <math.h>
PROGRAM
Click to edit Master title style
// Function to convert binary to decimal
int binaryToDecimal(long long binary){
int decimal = 0, i = 0, remainder;

printf("\n---------------------------------------------------------------------\n");
while (binary != 0) {
remainder = binary % 10;
binary /= 10;
decimal += remainder * pow(2, i); ++i; }
return decimal; }

// Function to convert decimal to binary


long long decimalToBinary(int decimal){
long long binary = 0;
int remainder, i = 1;
while (decimal != 0) {
remainder = decimal % 2;
decimal /= 2;
binary += remainder * i;
i *= 10; }
3 3
return binary;}
// Function to convert octal to binary

PROGRAM long long octalToBinary(int octal){


Click to edit Master title style
int decimal = 0, i = 0;
long long binary = 0;
// Convert octal to decimal
while (octal != 0) {
decimal += (octal % 10) * pow(8, i);
++i;
octal /= 10; }
i = 1;
// Convert decimal to binary
while (decimal != 0) {
binary += (decimal % 2) * i;
decimal /= 2;
i *= 10; }
return binary;} 4 4
int main(){
PROGRAM int choice;
Click to edit Master title style
long long binaryNumber;
int decimalNumber, octalNumber;
printf("\n\n\n-------------------------------------------- W E L C O M E -------------------------------
--------\n\n\n");
do {
// Display the menu
printf("\n\n = = = = = = = = = = = = = = = = = = = = NU M B E R -CO NV E R S IO N - M E NU
= = = = = = = = = = = = = = = = = = \n\n");
printf("1. Binary to Decimal\n");
printf("2. Decimal to Binary\n");
printf("3. Octal to Binary\n");
printf("4. Exit\n");
printf("\n\n Enter your choice: ");
scanf("%d", &choice); 5 5
switch (choice) {
case 1: // Binary to Decimal
Click
PROGRAM to edit Master title style
printf("Enter a binary number: ");
scanf("% lld", &binaryNumber);
printf("Decimal equivalent: %d\n", binaryToDecimal(binaryNumber));
break;
case 2: // Decimal to Binary
printf("Enter a decimal number: ");
scanf("%d", &decimalNumber);
printf("Binary equivalent: %lld\n", decimalToBinary(decimalNumber));
m break;
case 3: // Octal to Binary
printf("Enter an octal number: ");
scanf("%d", &octalNumber);
printf("Binary equivalent: %lld\n", octalToBinary(octalNumber));
break; 6 6
PROGRAM
Click to edit Master title style

case 4: // Exit the program


printf("Exiting the program. Goodbye!\n");
break;

default: printf("Invalid choice. Please enter a valid option.\n"); }


printf("\n\n******************************************************************************
**************************************************\n"); }

while (choice != 4); return 0;}

7 7
Click to
OUTPUT : edit Master title style

8 8
Click :to edit Master title style
OUTPUT

9 9
Click to edit Master title style
CONCLUSION

In conclusion, this number conversion system serves as a versatile tool for effortlessly
maneuvering between decimal, binary, and octal numeral systems. By offering functionalities to
convert decimal numbers to binary, binary to decimal, and octal to binary representations, this
code streamlines the process of understanding and working with diverse numerical bases. Its
algorithms ensure accuracy and efficiency in transformations, empowering users across
disciplines like computer science, mathematics, and digital electronics. With this system, users
gain a convenient method to explore and manipulate different numeral systems, enhancing their
understanding of fundamental numerical representations.

1010
Click to edit Master title style

Thank You : )

11

You might also like