Professional Documents
Culture Documents
C++ Program File
C++ Program File
C++ Program File
A
PROJECT REPORT
ON
“BINARY CONVERTER”
1 | Page
Project Report Binary Converter
CERTIFICATE
This is to certify that the project work entitled “BINARY
CONVERTER” for has been carried out by Archit Gupta,
Student of the Class XII A in order to fulfill the required
curriculum of the course “Computer Science Project Work”.
Project Guide:
Mrs.Monika Rohilla
PGT(Comp Sc.)
K.V. Sainik Vihar,
Delhi
2 | Page
Project Report Binary Converter
ACKNOWLEDGEMENT
3 | Page
Project Report Binary Converter
INDEX
1. Introduction
1.1 Introduction to Project
2. Selected Software
3. Coding
6. Conclusion
8. Bibliography
4 | Page
Project Report Binary Converter
INTRODUCTION
5 | Page
Project Report Binary Converter
Introduction to Project:
Selected Software:
- C++
6 | Page
Project Report Binary Converter
CODING
7 | Page
Project Report Binary Converter
// Binary Converter
/********************************************************/
/* Binary converter */
/*
/********************************************************/
/*using namespace std;*/
#include <iostream.h>
#include<string.h>
/*#include <cstring>*/
/*#include <cstdlib>*/
#include<stdlib.h>
int main()
{
prog();
return 0;
}
void prog()
{
entry = new char[501];
/* entry should be dynamic, otherwise a new
string entry of 501 chars would be created
each time function is called!
Talk about memory hog! */
cout<<"Enter string to convert (up to 500 chars): ";
cin.getline(entry, 500);
len = strlen(entry); /* get the number of characters in entry. */
/* this loop is executed for each letter in the string. */
for(int i = 0; i<len; i++)
8 | Page
Project Report Binary Converter
{
total = 0;
letter = entry[i]; /* store the first letter */
ascii = letter; /* put that letter into an int, so we can
see its ASCII number */
while(ascii>0) /* This while loop converts the ASCII # into binary,
stores it backwards into the binary array. */
{
/* To get the binary code one must take the decimal number in
question, take it and divide it by two repeatedly, save
the remainder (which will become the binary number), save
the whole number, divide by two, and repeat the whole
process until 0 is reached. This if-else statement serves
this functionality, by getting the remainder of the ascii
code, storing it in the array and then dividing the int
ascii by two */
if((ascii%2)==0)
{
binary[total] = 0;
ascii = ascii/2;
total++; /* increasing by one each time will yeild the
number of numbers in the array. */
}
else
{
binary[total] = 1;
ascii = ascii/2;
total++;
}
}
total--; /* due to data type factors, the program will actually
add a 0 at the end of the array that is not supposed
to be there, decrementing total will solve this
problem, as that 0 will not be displayed. */
/* this while loop displays the binary code for that letter. */
9 | Page
Project Report Binary Converter
while(total>=0)
{
cout<<binary[total];
total--;
}
}
delete[] entry; /* free up the memory used by entry */
cout<<endl<<"Do again(1 = yes, 2= no)?: ";
cin.getline(choice,3);
if(choice[0] == '1')
prog(); /* program is recursive, it calls itself. It's kinda
like a function loop of sorts. */
else
exit(0); /* quits the program */
}
10 | P a g e
Project Report Binary Converter
OUTPUT
11 | P a g e
Project Report Binary Converter
12 | P a g e
Project Report Binary Converter
TESTING
SYSTEM TESTING
13 | P a g e
Project Report Binary Converter
Conclusion:
14 | P a g e
Project Report Binary Converter
Bibliography:
15 | P a g e