Report Format Mini Project CSF101
Report Format Mini Project CSF101
Submitted to
Dr. Madhu Sharma
Assistant Professor
Submitted by: Tushar Mavi
SAP ID - 1000024679 Section - J
Group No - 1
SCHOOL OF COMPUTING
DIT UNIVERSITY, DEHRADUN
(State Private University through State Legislature Act No. 10 of 2013 of Uttarakhand and approved by UGC)
I hereby certify that the work, which is being presented in the Report, entitled “Number Base
Converter”, in partial fulfilment of the requirement as part of the course Programming for
Problem Solving of the Degree of Bachelor of Computer Science and Engineering and
submitted to the DIT University is an authentic record of my work carried out during the
period 12/10/2024 to 15/11/2024 under the guidance of Dr. Madhu Sharma.
Date: 9-11-2024
Signature of the Candidate
Binary (Base 2): The binary system consists of only two digits, 0
and 1. This system is mostly used as in machines where each
digit’s position represents a power of 2. For example, the binary
number 1101 is represented as (1 * 23) + (1 * 22) + (0 * 21) + (1 *
20).
Problem statement:
#include <stdio.h>
#include <stdlib.h>
void decimalToBinary(int n) {
if (n == 0) {
printf("0");
return;
}
int binary[32]; // Array to store binary number
int index = 0;
void decimalToOctal(int n) {
if (n == 0) {
printf("0");
return;
}
int octal[32]; // Array to store octal number
int index = 0;
while (n > 0) {
octal[index++] = n % 8; // Store remainder
n /= 8; // Divide by 8
void decimalToHexadecimal(int n) {
if (n == 0) {
printf("0");
return;
}
char hexadecimal[32]; // Array to store hexadecimal number
int index = 0;
while (n > 0) {
int remainder = n % 16;
if (remainder < 10) {
hexadecimal[index++] = remainder + '0'; // Convert to char
} else {
hexadecimal[index++] = remainder - 10 + 'A'; // Convert to char
}
int main() {
int number, baseFrom, baseTo;
System Requirements:
Hardware requirements
Processor : Intel Core i3
Ram : 8 GB
Disk space : 256 GB
software requirements
C
Mingw
Operating System : Windows 11
Result analysis
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
return decimalValue;
}
// Main function
int main() {
char number[20];
int base, targetBase;
char result[20];
return 0;
}
```
1. **toDecimal Function**:
- This function takes a string representation of a number and its base.
- It calculates the decimal value by iterating through each digit,
converting it according to its position, and summing the results.
2. **fromDecimal Function**:
- This function converts a decimal number to the specified target base.
3. **Main Function**:
- It prompts the user for input, calls the conversion functions, and
prints the result.
When you run the program, you can test various inputs and bases. For
example:
- Inputting `1010` in base `2` and converting to base `10` should yield
`10`.
- Inputting `A` in base `16` and converting to base `10` should yield
`10`.
To analyze the correctness of the results, you can compare them with
manual conversions or use known values.
Thus, in closure; number base converters are very crucial for converting numbers
from one place value system like Binary to another such as Decimal and octal or
hexadecimal. In computer science, engineering or in maths it is very important to
understand how these conversions work.
Key takeaways include:
1. Considering Bases: A number system has a base (referred to as “B” ) which is
the power of it. Binary is for base 2, decimal is for base 10, octal are Base-8 and
hexadecimal ones are those who have the Base of16. as in:
2. Conversion methods: Numerous techniques for conversion exist, this will11
Direct Conversion: converting between bases by complex mathematic calculations.
Place Value Method: To Know the value of each digit depending on its position.
Algorithmic Methods: Process involves applying a conversion algorithm.
3. Applications- It is used in programming, digital electronics and data
representation which help us to know how computers process numbers.
Bibliography
This can include reference of books, web links, and software used
Books
Online Resources
1. Wolfram Alpha. "Number Base Conversion." Retrieved from
Wolfram Alpha.