Hi,,
I have two questions as follows:
write a C++ program to convert an unsigned integer number to Binary.
wriet a C++ program to convert a Hexadecimal number to Binary.
I heard that is very easy but I can not write
so, please i want help from us as harry up as you can please.
6 1913
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.
Please read the Posting Guidelines and particularly the Coursework Posting Guidelines.
Then when you are ready post a new question in this thread.
MODERATOR
Thank you very much
I try more than once but i can not write anything so please help me
that becouse i don't have enough knowledge and practice on this material
Regardless, we are not going to do your work for you, whether you are an expert or a beginner. You need to read our Posting Guidelines, especially the points where we clearly tell you how to ask a question (and this thread is not a good example).
Hi,,
I have two questions as follows:
write a C++ program to convert an unsigned integer number to Binary.
wriet a C++ program to convert a Hexadecimal number to Binary.
I heard that is very easy but I can not write
so, please i want help from us as harry up as you can please.
I don't know who harry is but think of your own problem a bit: a number is a number
is a number, i.e. if I stick up three fingers it can represent the number three. If
you write down FF is can represent the number 255 (in decimal) for the hexadecimal
representation FF. You want different representations of one and the same number.
Scanf() and printf() format specifiers are quite good at that.
kind regards,
Jos
Hi,,
I have two questions as follows:
write a C++ program to convert an unsigned integer number to Binary.
wriet a C++ program to convert a Hexadecimal number to Binary.
I heard that is very easy but I can not write
so, please i want help from us as harry up as you can please.
Damn, seriously do your own work, and regarding this question, i have the same assignment and i'm from the same university...sheesh, UOB noobie...plus its an assignment ur suppose to do by yourself...
anyway
Here is how far I got on this program, was kinda pain to do but here is how I wrote it...
well its still in development, i'm stuck in the last addition part of the two's complement structure. or did i take the wrong path from the start? - #include <iostream>
-
using namespace std;
-
-
int main()
-
{
-
unsigned int num=0;
-
int size;
-
int myarray[20];
-
int count;
-
for (count = 19; count > 0; count--)
-
myarray[count]=0;
-
-
cout << "Enter number to convert to binary" << endl;
-
cin >> num;
-
-
for (size = 0; num > 0; size++) //Converting to Binary
-
{
-
myarray[size]=num%2;
-
num= num/2;
-
}
-
-
int i;
-
for (i=size-1; i >= 0; i--) //Printing Binary Number
-
{
-
cout << myarray[i];
-
}
-
cout << endl;
-
-
-
cout << "Applying Two's Complement" << endl;
-
-
for (i=size-1; i >= 0; i--) //Using Two's Complement.
-
{
-
if (myarray[i] == 0)
-
myarray[i] = 1;
-
else
-
myarray[i] = 0;
-
}
-
-
for (i=size-1; i >= 0; i--) //Printing converted Binary
-
{
-
cout << myarray[i];
-
}
-
cout << endl;
-
-
-
cout << "Adding One" << endl;
-
-
-
if (myarray[0] == 0)
-
myarray[0]++;
-
-
myarray[size]=1;
-
for (i=size; i >= 0; i--) //Output After Adding 1.
-
{
-
cout << myarray[i];
-
}
-
cout << endl;
-
-
return 0;
-
}
its cool fellas, i got the assignment working now, took it the wrong way....
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Aakash Bordia |
last post by:
Hello,
Does anybody know what is the documented and known behavior of
inserting/updating binary columns using host variables from a client to a
server which have different code pages? Will any...
|
by: Yodai |
last post by:
Hi all!
I have an int that comes with a value like 0x07fa and I have to turn it into
a float value of 204.2 decimal to display it.... if I try to divide it by
10 I get bogus numbers. I presume...
|
by: Rob Somers |
last post by:
Hey all
I am writing a program to keep track of expenses and so on - it is not
a school project, I am learning C as a hobby - At any rate, I am new
to structs and reading and writing to files,...
|
by: TTroy |
last post by:
Hello, I'm relatively new to C and have gone through more than 4 books
on it. None mentioned anything about integral promotion, arithmetic
conversion, value preserving and unsigned preserving. ...
|
by: Russell Warren |
last post by:
I've got a case where I want to convert binary blocks of data (various
ctypes objects) to base64 strings.
The conversion calls in the base64 module expect strings as input, so
right now I'm...
|
by: Jan Althaus |
last post by:
Mostly for testing reasons I'd like to see if it makes sense to chose
the following approach for just-in-time compilation of shaders for a
renderer:
Seeing as the shaders themsefs consist mostly...
|
by: ftjonsson |
last post by:
hello,
I was wondering if anyone could tips me on what I am doing wrong when
writing the following code:
#include <iostream>
using namespace std;
int main ()
{
|
by: Fumeur |
last post by:
Is the following program standard conform?
(reduced as much as possible so it still shows the problem)
/* begin */
#include <stdio.h>
void xfprintf(FILE *);
void xfprintf(FILE *f) {...
|
by: i_robot73 |
last post by:
I have a file, containing hex values for dates (MMDDYYYY)<status
code><??such as:
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |